1.Easy
What does GROUP BY do in a query?
- ASorts the rows of the result alphabetically
- BJoins two tables on their common columns
- CPuts rows with the same values into groups so aggregates are computed per group
- DRemoves rows with NULL values
2.Easy
Which rows does WHERE price BETWEEN 10 AND 20 select?
- ARows with price above 10 and below 20, excluding 10 and 20
- BRows with price outside the range 10 to 20
- CRows with price equal to 10 or 20 only
- DRows with price from 10 to 20, including 10 and 20
3.Easy
What does NULL represent in SQL?
- AA false Boolean
- BThe number zero in numeric columns
- CAn empty string
- DA missing or unknown value
4.Medium
Which ACID property means concurrent transactions do not see each other's unfinished changes?
- AAtomicity
- BIsolation
- CDurability
- DAvailability
5.Medium
A column holds the values 10, 20 and NULL. What does AVG(col) return?
- A10
- B30
- CNULL
- D15
6.Medium
Students can take many courses and courses have many students. How is this modelled in tables?
- ABy merging students and courses into one table
- BWith a list of course ids stored in one column
- CWith a junction table holding foreign keys to both students and courses
- DWith a foreign key column course_id in the students table pointing to courses
7.Hard
Which window function assigns 1, 2, 3, ... to rows within each partition without ties?
- ADENSE_RANK()
- BCOUNT()
- CROW_NUMBER()
- DRANK()
8.Hard
When is decomposing R into R1 and R2 guaranteed to be lossless?
- AWhen every attribute of R appears in both R1 and R2
- BWhen R1 and R2 have no attributes in common
- CWhen R1 and R2 have the same number of columns
- DWhen the common attributes of R1 and R2 form a superkey of R1 or of R2
Answer key
- 1. C · Puts rows with the same values into groups so aggregates are computed per group
- 2. D · Rows with price from 10 to 20, including 10 and 20
- 3. D · A missing or unknown value
- 4. B · Isolation
- 5. D · 15
- 6. C · With a junction table holding foreign keys to both students and courses
- 7. C · ROW_NUMBER()
- 8. D · When the common attributes of R1 and R2 form a superkey of R1 or of R2
Full step-by-step solutions: practise this topic on examproblems.com.