- Practice
- About 14 min
- 5 practice questions
Database mixed practice
Attempt mixed questions on tables, keys, SQL and design terms.
If something looks wrong, please tell us.
Mixed questions can combine a small table, a query and a definition. Work out the table first, then apply the query or term.
Revision table
| Cue | Answer |
|---|---|
| Row | Record |
| Column | Field |
| Unique identifier | Primary key |
| Points to another table | Foreign key |
| Retrieve data | SELECT |
| Reduce repeated data | Normalisation |
Worked examples
Example 1. A table Item has these prices: 40, 25, 60, 75. What does SELECT MAX(Price) return? 75, the largest price. And SUM(Price) = 40 + 25 + 60 + 75 = 200.
Example 2. An Orders table stores CustomerID that matches the ID in the Customer table. What is CustomerID in Orders? A foreign key.
Work out the table first, then apply the query or term.
Key takeaways: use the cue table and double-check boundary conditions in queries.
Check your understanding
-
1. Item table prices: 40, 25, 60, 75. What does SELECT MAX(Price) FROM Item; return?
- 75
- 60
- 40
- 200
Show answer
Answer: A. MAX returns the largest value, 75.
-
2. Item table prices: 40, 25, 60, 75. What does SELECT SUM(Price) FROM Item; return?
- 190
- 200
- 175
- 50
Show answer
Answer: B. 40 + 25 + 60 + 75 = 200.
-
3. Item table prices: 40, 25, 60, 75. What does SELECT AVG(Price) FROM Item; return?
- 40
- 60
- 50
- 200
Show answer
Answer: C. Sum 200 divided by 4 items = 50.
-
4. An Orders table stores CustomerID, which matches the ID in the Customer table. In Orders, CustomerID is a
- Primary key of Orders
- Composite key
- Data dictionary
- Foreign key
Show answer
Answer: D. It refers to the primary key of another table, so it is a foreign key.
-
5. A table has 12 rows and 5 columns. How many fields does it have?
- 5
- 12
- 60
- 17
Show answer
Answer: A. Fields are columns, so 5. (12 is the number of records.)
Sign in to keep track of the lessons you finish.