Tables, keys and constraints
An entry references an existing book and stores pages read. Identify the constraints needed to reject missing books and negative counts.
Examples
Example 1
Input
Book ID must exist
Expected output
Foreign key
Example 2
Input
Pages read must be zero or greater
Expected output
Check constraint
Hints and solution
Hint 1
One rule relates two tables, and the other compares a number.
Reveal worked answer
Use a foreign key to reference the books table and a check constraint to require pages read to be at least zero.