Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Subject:
Topics:
Avg
score:
–
Topics
done:
0/32

Single-table databases, data types and primary keys

Practise 34 exam-style questions on Single-table databases, data types and primary keys for Cambridge IGCSE Computer Science (Paper 2). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with an AI tutor on hand if you get stuck.

  • 34 questions
  • 1–7 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

A bus company's database table has a field that stores the time each bus is due to leave the bus station, for example 14:35.

State the most suitable data type for this field.

Model answer

Date/time

Explanation

Times and dates should use the date/time data type so that only valid times can be stored and they can be sorted and compared in time order. Stored as text or as a real number, 14:35 could not be checked or compared properly.

Mark scheme
  1. 1 mark

    Date/time

    Accept time. Do not accept real or text.

Question 2

2 marks

Give two reasons why validation checks are used when data is entered into a database table.

Model answer

Validation stops invalid data, such as an age of 250 or a missing name, from being stored. This means that searches and queries on the table give sensible results.

Explanation

Validation is automatic checking by the computer that data is reasonable and follows rules. It cannot prove that the data is correct, only that it is acceptable; for example, a wrong but sensible age will still be accepted.

Mark scheme
  1. 1 mark

    Any two from: to make sure the data entered is reasonable/sensible/follows set rules; to stop invalid or impossible data being stored; to make sure required data is not missing; so that searches, queries and calculations on the data give correct results; to reduce errors that would be difficult to find later

    1 mark for each different reason, max 2. Do not accept 'to make sure the data is correct' (validation cannot guarantee this).

  2. 1 mark

    Second different reason from the list above

Question 3

3 marks

A teacher wants a single-table database to store, for each of the 28 students in her class: first name, last name, date of birth and test score. Each student will have one record.

State the number of records and the number of fields the table would have, and explain why an extra field may be needed.

Model answer

There would be 28 records (one per student) and 4 fields (FirstName, LastName, DateOfBirth and TestScore). An extra field, such as StudentID, may be needed because none of these fields is guaranteed to be unique, so it is needed to act as the primary key.

Explanation

Each item stored about every student becomes a field and each student becomes a record. A table also needs a primary key, and names, dates of birth and scores can all repeat.

Mark scheme
  1. 1 mark

    28 records

  2. 1 mark

    4 fields

    Accept 5 fields if the student includes the extra ID field and says so.

  3. 1 mark

    None of the fields is certain to be unique (two students may share a name or date of birth), so an extra field such as StudentID is needed as a primary key

Question 4

5 marks

The table shows part of a vet's database table, Pets.

State the most suitable data type for each of the five fields.

Table: Pets. Table with columns "PetID", "PetName", "DateOfBirth", "WeightKg", "Neutered". PetID: PT001; PetName: Biscuit; DateOfBirth: 12/04/2021; WeightKg: 8.4; Neutered: TRUE | PetID: PT002; PetName: Luna; DateOfBirth: 03/11/2019; WeightKg: 4.1; Neutered: FALSE | PetID: PT003; PetName: Max; DateOfBirth: 27/06/2023; WeightKg: 31.6; Neutered: TRUE | PetID: PT004; PetName: Pip; DateOfBirth: 15/01/2024; WeightKg: 0.9; Neutered: FALSE.

Model answer

PetID: text/alphanumeric
PetName: text/alphanumeric
DateOfBirth: date/time
WeightKg: real
Neutered: Boolean

Explanation

Look at the sample data for each field. PetID mixes letters and digits, so it is text; weights such as 8.4 need a real number; and TRUE/FALSE values are Boolean. Dates should always use date/time.

Mark scheme
  1. 1 mark

    PetID: text/alphanumeric

    The values contain letters.

  2. 1 mark

    PetName: text/alphanumeric

  3. 1 mark

    DateOfBirth: date/time

  4. 1 mark

    WeightKg: real

  5. 1 mark

    Neutered: Boolean

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

AI Tutor Hints first, answers after you try

Hi! Stuck? Ask me for a hint and I’ll help you work it out. Once you’ve checked your answer I can explain exactly where the marks are.