SYLLABUS 9.1–9.3 · PAPER 2 · ALSO FOR 0984 AND 2210

Databases: tables, fields, records, data types and primary keys

The syllabus uses single-table databases. You need to be able to describe one, choose a data type for each field, and pick the field that makes a good primary key.

Tables, records and fields

A table holds data about one kind of thing, such as books or members. Each row is a record: all the data about one book. Each column is a field: one piece of data, such as the title, stored for every record.

Data types

  • Text / alphanumeric: letters, digits and symbols, such as a name or a postcode.
  • Character: a single character, such as a size code M.
  • Boolean: one of two values, such as TRUE for “in stock”.
  • Integer: a whole number, such as the number of copies.
  • Real: a number with decimal places, such as a price.
  • Date/time: a date or time, such as the date a book was borrowed.

Primary keys

A primary key is a field whose value is different for every record, so each record can be found on its own. A made-up ID such as MemberID works well. A name doesn’t, because two people can share one.

Where marks go

  • Mixing up record (a row) and field (a column).
  • Choosing integer for a phone number or ID that could start with 0 or contain letters.
  • Picking a primary key that could repeat, such as a surname or a date.
  • Saying a primary key must be a number: it only has to be unique.
  • Choosing text for a yes/no field that should be Boolean.

Try a question

4 MARKS · MARKED ON THIS PAGE

A hockey club stores data about its members in a table called MEMBER, shown above. Complete the grid by answering each question about the table. Give field names exactly as they appear in the table.

MEMBER

MemberIDSurnameTeamAgeGroupFeesPaid
M201OkaforHawksU14TRUE
M202LindqvistFalconsU16FALSE
M203OkaforFalconsU16TRUE
M204PatelHawksU14TRUE
M205MoreauEaglesU18FALSE
M206TanakaEaglesU18TRUE
M207SilvaHawksU16TRUE
QuestionAnswer
Number of fields in MEMBER
Number of records in MEMBER
Field that should be the primary key
One field that cannot be the primary key because it contains a repeated value
Fill in your answer first.