Course outline
Module 1
Module 1: What Is a Database?
What Is a Database?
Knowledge check
Q1. What is the most basic definition of a database?
- A. A single spreadsheet file stored on one computer
- B. An organized collection of data that can be easily accessed, managed, and updated ✓
- C. A type of computer hardware used to store files
- D. A program that only allows users to write documents
Why: A database is an organized collection of data designed so that it can be efficiently stored, accessed, managed, and updated. Options A and C describe storage formats or hardware rather than the organized data collection itself, and option D describes a word processor.
Q2. Which of the following is a common real-world example of a database?
- A. A paper filing cabinet with no index
- B. A loose pile of receipts in a shoebox
- C. A phone's contact list ✓
- D. A blank notebook
Why: A phone's contact list stores names, numbers, and other details in an organized way that can be searched and updated, making it a simple database. The other options lack organization or structure for easy retrieval.
Q3. What is a DBMS?
- A. A type of data stored in a database
- B. A Database Management System, software that lets users create, read, update, and delete data ✓
- C. A hardware device that connects computers to the internet
- D. A table within a database
Why: A DBMS (Database Management System) is the software that manages databases, allowing users to create, read, update, and delete data. Examples include MySQL and PostgreSQL.
Q4. Why are databases preferred over simple files for storing large amounts of information?
- A. Databases cannot store text
- B. Databases make it harder to find information
- C. Databases support faster searching, reduce duplication, and help keep data consistent ✓
- D. Databases can only store numbers
Why: Databases are designed to search quickly, minimize redundant copies of data, and enforce consistency rules, which become essential as data volume grows. They can store many data types, including text, and are built to make information easier to find, not harder.
Q5. In everyday terms, what is a 'record' in a database?
- A. A single complete entry about one item, such as one customer's details ✓
- B. The name of the database software
- C. A backup copy of the entire database
- D. A password used to access the database
Why: A record is a single complete entry in a database, such as all the information about one customer, one product, or one order. Records are typically organized as rows within a table.
Module 2
Module 2: Tables, Rows, and Columns
Tables, Rows, and Columns
Knowledge check
Q1. What is a table in a database?
- A. A single piece of data stored in one cell
- B. A structured collection of related data organized into rows and columns ✓
- C. A program that runs queries on the server
- D. A backup copy of the entire database
Why: A table is a structured collection of related data. It organizes information into rows, where each row is one record, and columns, where each column holds one type of attribute for that record.
Q2. In a table of customers, what would a single row typically represent?
- A. One attribute, such as everyone's email address
- B. The name of the table itself
- C. One complete customer record ✓
- D. The total number of customers in the database
Why: Each row represents one individual record. In a customers table, a single row holds all the information about one specific customer, such as their name, email, and phone number.
Q3. What is a column in a database table?
- A. A single record containing all details about one item
- B. A vertical set of values that all share the same attribute or data type ✓
- C. A rule that prevents duplicate entries
- D. A connection between two different tables
Why: A column holds one attribute across all rows, such as every customer's email address. All values in a column share the same meaning and usually the same data type.
Q4. Which term describes the intersection of one row and one column in a table?
- A. A key
- B. A cell ✓
- C. A schema
- D. An index
Why: A cell is the single point where a row and a column meet. It holds one specific value, such as the email address of one particular customer.
Q5. Why is it important to give each column a clear, descriptive name?
- A. It makes the table load faster on the server
- B. It determines how many rows the table can hold
- C. It helps people and programs understand what data each column contains ✓
- D. It automatically encrypts the data in that column
Why: Clear column names make tables understandable to people and make queries easier to write correctly. Names like 'email' or 'birth_date' communicate meaning, whereas names like 'col1' do not.
Module 3
Module 3: Keys and How Data Connects
Keys and How Data Connects
Knowledge check
Q1. What is a primary key in a database table?
- A. A password that protects the table from unauthorized access
- B. A column (or set of columns) that uniquely identifies each row in a table ✓
- C. The first column that users type data into
- D. A backup copy of the table's data
Why: A primary key uniquely identifies each row, so no two rows can share the same primary key value. This is what allows the database to find, update, or delete one specific record reliably.
Q2. Why can't a primary key column contain NULL values?
- A. NULL values take up too much storage space
- B. NULL values would make it impossible to uniquely identify a row ✓
- C. NULL is reserved only for foreign keys
- D. Databases automatically convert NULL to zero in primary keys
Why: If a row had a NULL primary key, the database could not reliably identify that row, which defeats the purpose of a primary key. That is why primary key columns must always contain a value.
Q3. What is a foreign key?
- A. A key that is stored in a separate file outside the database
- B. A column in one table that refers to the primary key of another table ✓
- C. A key used to encrypt data sent between countries
- D. A duplicate copy of a table's primary key in the same table
Why: A foreign key links two tables together. For example, an orders table might have a customer_id column that points to the primary key of a customers table, showing which customer placed each order.
Q4. A students table has a student_id primary key, and a courses table has a course_id primary key. Which design correctly records which students are enrolled in which courses?
- A. Add a list of course names inside the students table
- B. Create a separate enrollments table that holds student_id and course_id pairs ✓
- C. Add every student's name as a column in the courses table
- D. Store the enrollments in the primary key of the students table
Why: Students can take many courses and courses have many students, which is a many-to-many relationship. A separate enrollments table (sometimes called a junction table) holds pairs of foreign keys that connect the two tables cleanly.
Q5. What does it mean if a table has a composite primary key?
- A. The table has more than one primary key in separate tables
- B. The primary key is made up of two or more columns together ✓
- C. The primary key is stored in encrypted form
- D. The table is linked to every other table in the database
Why: A composite primary key uses multiple columns together to make each row unique. For example, an enrollments table might use the combination of student_id and course_id as its primary key, since neither column alone is unique.
Module 4
Module 4: Asking Questions with SQL
Asking Questions with SQL
Knowledge check
Q1. What is the main purpose of the SELECT statement in SQL?
- A. To delete rows from a table
- B. To retrieve data from one or more tables ✓
- C. To create a new database
- D. To change the structure of a table
Why: SELECT is the SQL command used to query and retrieve data from tables. It lets you specify which columns you want to see and, with other clauses, which rows to return.
Q2. Which SQL clause is used to filter rows based on a condition?
- A. ORDER BY
- B. GROUP BY
- C. WHERE ✓
- D. HAVING
Why: The WHERE clause filters rows before any grouping takes place, keeping only the rows that meet the specified condition. For example, WHERE age > 30 returns only rows where age is greater than 30.
Q3. What does the following query return? SELECT name FROM students ORDER BY name;
- A. Only the first student's name
- B. All columns of the students table, unsorted
- C. The names of all students, sorted alphabetically ✓
- D. The number of students
Why: SELECT name chooses the name column, and ORDER BY name sorts the results in ascending (alphabetical) order by default. ORDER BY does not change which rows are returned, only their order.
Q4. Which function would you use to count the number of rows in a table?
- A. SUM()
- B. AVG()
- C. COUNT() ✓
- D. MAX()
Why: COUNT() is an aggregate function that returns the number of rows, such as SELECT COUNT(*) FROM orders;. SUM() adds values, AVG() calculates the average, and MAX() finds the largest value.
Q5. What keyword is used to remove duplicate rows from query results?
- A. UNIQUE
- B. DISTINCT ✓
- C. DIFFERENT
- D. SINGLE
Why: DISTINCT, as in SELECT DISTINCT city FROM customers;, removes duplicate values from the result set so each value appears only once. UNIQUE is a constraint keyword in table definitions, not a query modifier.
Module 5
Module 5: Organizing Data With Good Design
Organizing Data With Good Design
Knowledge check
Q1. What is the main purpose of organizing data into separate tables in a database?
- A. To make the database file larger
- B. To reduce duplicate information and keep related data organized ✓
- C. To make it impossible to search for data
- D. To store data only in one long list
Why: Separating data into tables keeps each type of information in its own place, which reduces repetition and makes the data easier to maintain and understand.
Q2. In a database table, what is a row also commonly called?
- A. A field
- B. A record ✓
- C. A key
- D. A schema
Why: Each row in a table represents one complete record, such as a single customer or a single order.
Q3. What is a primary key?
- A. A password that protects the database
- B. A column that uniquely identifies each row in a table ✓
- C. The first column in any table regardless of its contents
- D. A command used to delete data
Why: A primary key holds a unique value for each row, so every record can be reliably identified and linked to others.
Q4. Why is it a good idea to avoid storing the same information in multiple places?
- A. Duplicate data always causes the database to crash
- B. Repeated data takes up space and can become inconsistent when updated in only one place ✓
- C. Databases cannot store the same word twice
- D. It makes the data easier to search in every case
Why: When the same fact is stored in several places, updating one copy but not the others leads to conflicting and unreliable information.
Q5. What is a foreign key used for?
- A. To encrypt data in a table
- B. To link a row in one table to a related row in another table ✓
- C. To rename a table
- D. To store images inside a database
Why: A foreign key references the primary key of another table, creating a relationship that connects related information together.
Module 6
Module 6: Keeping Data Accurate and Safe
Keeping Data Accurate and Safe
Knowledge check
Q1. What is the main purpose of a database constraint?
- A. To make queries run faster by caching results
- B. To enforce rules that keep data valid and consistent ✓
- C. To compress data so it takes up less storage space
- D. To automatically back up data to another server
Why: Constraints such as NOT NULL, UNIQUE, and CHECK enforce rules on the data itself, so invalid or inconsistent values are rejected before they are stored.
Q2. Which constraint ensures that no two rows in a table have the same value in a particular column?
- A. NOT NULL
- B. FOREIGN KEY
- C. UNIQUE ✓
- D. DEFAULT
Why: A UNIQUE constraint prevents duplicate values in the column it applies to, such as two customers sharing the same email address.
Q3. What does a FOREIGN KEY constraint do?
- A. It encrypts the values stored in a column
- B. It requires a value to match an existing value in another table ✓
- C. It automatically sorts rows in ascending order
- D. It hides a column from users who lack permission
Why: A foreign key links a column to a primary key in another table, ensuring that references point to records that actually exist, which protects relationships between tables.
Q4. What is a backup in the context of database safety?
- A. A copy of data stored separately so it can be restored after loss or damage ✓
- B. A second user account with administrator rights
- C. A temporary table used during query processing
- D. An index that speeds up searches for deleted records
Why: Backups are saved copies of data kept apart from the live database, allowing recovery from hardware failure, accidental deletion, or corruption.
Q5. Why is access control important for keeping a database safe?
- A. It limits who can view or change data, reducing the risk of misuse or accidental damage ✓
- B. It increases the speed at which data can be written
- C. It removes the need for backups entirely
- D. It converts data into a format that uses less memory
Why: Access control gives each user only the permissions they need, so sensitive data is protected and fewer people can accidentally or deliberately alter important records.
Module 7
Module 7: Databases in Everyday Life
Databases in Everyday Life
Knowledge check
Q1. Which of these everyday activities most directly relies on a database?
- A. Boiling water in a kettle
- B. Checking your bank balance in a mobile app ✓
- C. Walking up a flight of stairs
- D. Reading a paper book
Why: A bank balance is stored and retrieved from a database, which keeps track of account records and transactions so the app can display current information.
Q2. What is a database best described as?
- A. A single spreadsheet cell that holds one number
- B. An organized collection of data that can be stored, searched, and updated ✓
- C. A type of computer keyboard
- D. A program that only deletes old files
Why: A database is an organized collection of data designed so it can be efficiently stored, searched, updated, and managed.
Q3. When you search for a product on an online shopping website, what is the database primarily doing?
- A. Printing the product catalog
- B. Finding and returning records that match your search terms ✓
- C. Charging your credit card
- D. Shipping the item to your house
Why: The website queries the product database to find and return the records that match your search, such as item name, price, and availability.
Q4. Why does a library's catalog system use a database instead of paper cards alone?
- A. Databases make books heavier and more durable
- B. Databases let staff quickly search, sort, and update records like titles, authors, and availability ✓
- C. Databases remove the need for librarians
- D. Databases are required by law to replace books
Why: A database lets staff and patrons quickly search by title, author, or subject, and update availability instantly when books are borrowed or returned.
Q5. Which term describes a database field that uniquely identifies each record, such as a customer ID number?
- A. Primary key ✓
- B. Background color
- C. Screen resolution
- D. File extension
Why: A primary key is a field whose values are unique for each record, letting the database reliably distinguish one record from another, like two customers with the same name.