Tables, fields and keys
Answers are for parents and teachers.
1
Look at the members table. Write the number of fields, the number of records, and the value of books_read for Karim.
4 fields, 5 records, books_read of Karim is 6.
2
Choose text, integer, decimal or date: (a) a book title, (b) the number of pages, (c) the price in pounds with piastres, (d) the day a book was borrowed.
(a) text; (b) integer; (c) decimal; (d) date.
3
A table of books has the fields title, writer and shelf. Can title be the primary key? Explain, and suggest a better one.
No: two copies or editions may share a title, so it can repeat. Add a field book_id with a different number for each book.
4
A flat table repeats the shelf room for 40 books. The room is renamed. How many rows must be edited? And in a table of shelves with one row per shelf?
40 rows in the flat table; 1 row in the table of shelves (if all 40 books share one shelf).
5
Why must a primary key never be empty?
An empty value cannot identify any record.