Web Development Database Basics 2 — Questions and Answers
Question 1: Which SQL clause filters rows AFTER aggregation has been applied?
- WHERE
- HAVING (Correct answer)
- FILTER
- GROUP BY
Correct answer: HAVING
HAVING filters grouped/aggregated results, whereas WHERE filters individual rows before grouping.
Question 2: What does the term 'cardinality' refer to in a database relationship?
- The number of columns in a table
- The uniqueness of values in a column
- The number of rows in a table
- The number of related records between two entities (Correct answer)
Correct answer: The number of related records between two entities
Cardinality describes how many instances of one entity relate to instances of another (one-to-one, one-to-many, many-to-many).
Question 3: Which isolation level prevents dirty reads but still allows non-repeatable reads?
- Read Uncommitted
- Read Committed (Correct answer)
- Repeatable Read
- Serializable
Correct answer: Read Committed
Read Committed prevents dirty reads by only reading committed data but allows non-repeatable reads if another transaction commits between reads.
Question 4: What is a composite key?
- A key that references another table
- A key made up of two or more columns (Correct answer)
- A key that auto-increments
- A key encrypted for security
Correct answer: A key made up of two or more columns
A composite key uses two or more columns together to uniquely identify a row in a table.
Question 5: Which type of JOIN returns only rows where there is a match in BOTH tables?
- LEFT JOIN
- RIGHT JOIN
- INNER JOIN (Correct answer)
- FULL OUTER JOIN
Correct answer: INNER JOIN
INNER JOIN returns only the rows that have matching values in both joined tables.
Question 6: What does DDL stand for in SQL?
- Data Definition Language (Correct answer)
- Data Deletion Logic
- Dynamic Data Layer
- Database Design Layout
Correct answer: Data Definition Language
DDL (Data Definition Language) includes commands like CREATE, ALTER, and DROP that define database structure.
Question 7: Which normal form eliminates transitive dependencies?
- 1NF
- 2NF
- 3NF (Correct answer)
- BCNF
Correct answer: 3NF
Third Normal Form (3NF) requires that non-key columns depend only on the primary key, eliminating transitive dependencies.
Which SQL clause filters rows AFTER aggregation has been applied?