Databases & SQL worksheet with answers

Free printable Databases & SQL worksheet: 8 problems from easy to exam level, with an answer key. Print it or save it as a PDF.

For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.

Name: ____________________   Date: ____________

1.Easy

Which SQL statement changes values in rows that already exist?

  1. AMODIFY
  2. BINSERT
  3. CREPLACE COLUMN
  4. DUPDATE
2.Easy

What is an entity-relationship (ER) diagram used for?

  1. AListing the users of a database
  2. BModelling entities, their attributes and relationships when designing a database
  3. CShowing how a query is executed
  4. DMeasuring database performance
3.Easy

GRANT and REVOKE belong to which part of SQL?

  1. AData Query Language (DQL)
  2. BData Manipulation Language (DML)
  3. CData Control Language (DCL)
  4. DData Definition Language (DDL)
4.Medium

Which ACID property guarantees that committed changes survive a system crash?

  1. AConsistency
  2. BIsolation
  3. CDurability
  4. DAtomicity
5.Medium

Third normal form (3NF) removes:

  1. AAtomic values
  2. BComposite keys
  3. CRedundant indexes on columns that are not part of a key
  4. DTransitive dependencies between non-key attributes
6.Medium

Students can take many courses and courses have many students. How is this modelled in tables?

  1. AWith a junction table holding foreign keys to both students and courses
  2. BWith a list of course ids stored in one column
  3. CWith a foreign key column course_id in the students table pointing to courses
  4. DBy merging students and courses into one table
7.Hard

Two-phase locking (2PL) ensures:

  1. AThat transactions never wait
  2. BThat no locks are needed
  3. CConflict-serializable schedules
  4. DThat deadlocks can never happen
8.Hard

Given the functional dependencies A → B, B → C and C → D on R(A, B, C, D), what is the closure A+?

  1. A{A, B, C}
  2. B{A, B}
  3. C{A, B, C, D}
  4. D{A}

Answer key

  1. 1. D · UPDATE
  2. 2. B · Modelling entities, their attributes and relationships when designing a database
  3. 3. C · Data Control Language (DCL)
  4. 4. C · Durability
  5. 5. D · Transitive dependencies between non-key attributes
  6. 6. A · With a junction table holding foreign keys to both students and courses
  7. 7. C · Conflict-serializable schedules
  8. 8. C · {A, B, C, D}

Full step-by-step solutions: practise this topic on examproblems.com.