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 statement deletes a whole table, including its structure?

  1. AREMOVE TABLE
  2. BDELETE FROM
  3. CTRUNCATE ROWS
  4. DDROP TABLE
2.Easy

A foreign key is:

  1. AA column whose values must be unique across all rows of the table
  2. BA column that refers to the primary key of another table
  3. CA key that is always encrypted
  4. DA key used by foreign users
3.Easy

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

  1. AMeasuring database performance
  2. BModelling entities, their attributes and relationships when designing a database
  3. CListing the users of a database
  4. DShowing how a query is executed
4.Medium

Which ACID property means concurrent transactions do not see each other's unfinished changes?

  1. ADurability
  2. BIsolation
  3. CAtomicity
  4. DAvailability
5.Medium

Why can a table have only one clustered index?

  1. AClustered indexes use too much memory
  2. BThe SQL standard forbids more than one index on a table
  3. CClustered indexes can only be on the primary key
  4. DThe rows can be stored physically in only one order
6.Medium

Table a has 3 rows and table b has 4 rows. How many rows does SELECT * FROM a CROSS JOIN b return?

  1. A7
  2. B3
  3. C4
  4. D12
7.Hard

When is a schedule of concurrent transactions called serializable?

  1. AWhen the transactions run on one CPU only
  2. BWhen every transaction is given a serial number
  3. CWhen its effect is equivalent to some serial execution of the same transactions
  4. DWhen no transaction ever reads data
8.Hard

What is a covering index for a query?

  1. AAn index that covers every column of every table
  2. BAn index on the primary key only
  3. CAn index that contains all columns the query needs, so the table itself need not be read
  4. DAn index that is rebuilt every night

Answer key

  1. 1. D · DROP TABLE
  2. 2. B · A column that refers to the primary key of another table
  3. 3. B · Modelling entities, their attributes and relationships when designing a database
  4. 4. B · Isolation
  5. 5. D · The rows can be stored physically in only one order
  6. 6. D · 12
  7. 7. C · When its effect is equivalent to some serial execution of the same transactions
  8. 8. C · An index that contains all columns the query needs, so the table itself need not be read

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