Skip to the page
Year 10 · ICT · Spring 1 · Effects of IT and ICT applications; databases

Practical: a database from a spec

PracticalPresent ▶

What this lesson covers

18.1 Create a database structure

Cambridge IGCSE ICT 0417 · Topic 18: Databases · Paper 2

You will learn to

  • Import a .csv file into a new table, keeping the field names from the first row.
  • Choose the right field type and display format for each field.
  • Set a primary key and add validation to fields, as the specification asks.

Success criteria

  • I can import the data file and check each field has the right type.
  • I can explain why a phone number is stored as text, not as a number.
  • I can set a primary key and say why its values are unique.
The syllabus points for this section
  • Import a .csv or .txt file and keep the field names from the first row.
  • Choose the right field type and sub-type for each field.
  • Set display formats for dates, currency, decimals and Boolean fields.
  • Set primary and foreign keys and build a one-to-many relationship.
  • Compare flat-file and relational databases.
  • Design a clear data entry form with suitable controls.

Key words

Say each word, then read what it means. Every one is in the glossary too.

Database
An organised store of data that can be searched, sorted and reported on.
Table
A set of records about one kind of thing, such as members or bookings.
Record
One row of a table: all the data about one item.
Field
One column of a table: one piece of data stored for every record.
Field type
The kind of data a field holds: text, numeric, date/time or Boolean.
Boolean
A field type with only two values, such as Yes/No or True/False.
Display format
How a value looks on screen or paper, without changing the stored value.
Primary key
A field whose value is different for every record, used to identify each one.
Foreign key
A field in one table that holds the primary key of another table, to link them.
One-to-many relationship
A link where one record in a table matches many records in another table.
Flat-file database
A database with only one table.
Relational database
A database with two or more tables linked by keys.
.csv file
A plain-text file where each line is a record and commas separate the fields.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

Tables, records and fields

A database is an organised store of data that a computer can search and sort.

Data sits in tables. A record is one row: all the data about one thing, such as one member.

A field is one column: one piece of data about every record, such as LastName.

Through this topic we use one example: a sports centre in Madrid. It has a Members table and a Bookings table.

MemberIDFirstNameLastNameCategoryPhoneDiscount
M01LucíaGarcíaJunior612 345 67820%
M02PabloRuizAdult655 210 9870%
M03CarmenLópezSenior699 004 32130%
M04DiegoMartínAdult634 778 1200%
M05SofíaNavarroJunior617 556 04320%
?Why?

Splitting data into fields lets the software search one field at a time. You can ask for every Junior member without reading every row yourself.

Import a .csv or .txt file

In the exam you do not type the data. Cambridge gives you a source file, usually .csv (comma separated values) or .txt.

A .csv file is plain text. Each line is one record. Commas separate the fields.

When you import, tell the software that the first row contains field names. Then the headings become field names, not a record.

During the import you can set each field's type and choose the primary key. Check the result against the source file after importing.

BookingID,MemberID,Activity,BookDate,Hours,Rate,Paid
101,M02,Padel,06/10/2026,1.5,12.00,Yes
102,M01,Swimming,06/10/2026,1,4.50,Yes
103,M04,Tennis,07/10/2026,2,11.00,No
!Watch out

If you forget to tick "first row contains field names", the headings become record 1 and every field gets a name like Field1. The examiner cannot see the field names you were asked to use.

Field types and sub-types

A field type (data type) tells the software what kind of data a field holds. It controls how data is stored, checked and sorted.

Cambridge names four main types: text, numeric, date/time and Boolean. Numeric has sub-types: integer, decimal, currency and percentage.

The table shows each type with a field from our sports centre.

TypeSub-typeWhat it holdsOur fieldExample
TextLetters, symbols, or digits not used for mathsMemberID, LastName, PhoneM04, Martín, 634 778 120
NumericIntegerWhole numbers onlyBookingID103
NumericDecimalNumbers with a fractional partHours1.5
NumericCurrencyMoney, shown with a symbol and 2 decimal placesRate€12.00
NumericPercentageA part of 100, often stored as a decimalDiscount20% (stored as 0.2)
Date/timeA date, a time, or bothBookDate07/10/2026
BooleanOnly two values: Yes/No or True/FalsePaidNo
!Watch out

Phone numbers are text, not numeric. You never add or average them. A numeric field also drops a leading zero or a "+34" and cannot store spaces.

Why the wrong type loses marks

The examiner checks your table design. Each wrong type usually costs a mark.

If Hours is set to integer, the value 1.5 is stored as a whole number. The cost of booking 101 is then wrong too.

If BookDate is text, sorting goes by characters, not by date. "06/11/2026" (6 November) sorts before "10/10/2026" (10 October), because 0 comes before 1.

If Paid is text, someone can type "yes", "Y" or "paid". A Boolean field only allows two values, so searches work every time.

?Why?

The type is a promise about the data. Keeping that promise makes searching, sorting and calculating reliable.

!Watch out

Your screenshot of the table design must show every field name in full and its type. Widen the column before you take the screenshot.

Display formats

A display format changes how a value looks, not the value stored.

Dates can show as 07/10/2026 or 7 October 2026. Currency shows a symbol and 2 decimal places, such as €4.50.

Decimal fields can show a set number of places: Hours as 1.0, 1.5, 2.0. A Boolean field can show as Yes/No or as a check box.

Read the task carefully. If it says "currency in euros with 2 decimal places", both parts are marked.

e.g.Example
Rate stored: 4.5 Display format: currency, euro, 2 decimal places Shown on screen: €4.50 Discount stored: 0.3 Display format: percentage, 0 decimal places Shown on screen: 30%
!Watch out

Formatting to 0 decimal places only hides the decimals. The value 1.5 still shows as 2 on screen, which looks wrong. Choose the places the task asks for.

Primary keys and foreign keys

A primary key is a field that holds a different value for every record. It identifies each record exactly. MemberID is the primary key of Members.

BookingID is the primary key of Bookings. Two bookings can share a member, an activity or a date, but never a BookingID.

A foreign key is a field in one table that is the primary key of another table. MemberID in Bookings is a foreign key. It tells you who made each booking.

BookingIDMemberIDActivityBookDateHoursRatePaid
101M02Padel06/10/20261.5€12.00Yes
102M01Swimming06/10/20261.0€4.50Yes
103M04Tennis07/10/20262.0€11.00No
104M02Swimming08/10/20261.0€4.50Yes
105M03Pilates08/10/20261.0€8.00No
106M05Padel09/10/20261.0€12.00No
107M04Padel10/10/20262.0€12.00Yes
108M01Tennis10/10/20261.0€11.00Yes
!Watch out

A name is a poor primary key. Two members can both be called Lucía García. Use an ID that the system gives out once.

One-to-many relationships

A relationship links two tables through a shared field. Here the link is MemberID.

It is one-to-many: one member can make many bookings, but each booking belongs to one member.

The "one" side is the primary key (Members.MemberID). The "many" side is the foreign key (Bookings.MemberID).

Many programs let you switch on referential integrity. Then you cannot add a booking for a member who does not exist, such as M09.

e.g.Example
M01 (Lucía García) → bookings 102 and 108 M02 (Pablo Ruiz) → bookings 101 and 104 M03 (Carmen López) → booking 105 M04 (Diego Martín) → bookings 103 and 107 M05 (Sofía Navarro) → booking 106

There is a diagram for this step in the IGCSE library.

Flat-file and relational databases

A flat-file database has one table. A relational database has two or more linked tables.

In a flat file, Pablo Ruiz's name and phone would be typed again on every booking he makes.

Repeated data wastes space and causes mistakes. If Pablo changes phone, you must find and change every copy.

Flat-fileRelational
TablesOneTwo or more, linked by keys
Repeated dataA lot (member details on every booking)Little (member details stored once)
UpdatingChange every copy; easy to miss oneChange once in Members
Set upQuick and simpleNeeds keys and relationships planned
Good forSmall, simple listsLarger data with links, like bookings
?Why?

Storing each fact once means it can only be wrong in one place. That keeps the data consistent.

Data entry forms

A data entry form shows one record at a time so a person can type data into a table. Good forms reduce typing errors.

Use radio buttons when the user must pick exactly one of a few options: Category is Junior, Adult or Senior.

Use a check box for a Boolean field: Paid is ticked or not.

Use a drop-down menu for a longer fixed list: Activity is Padel, Pilates, Swimming or Tennis.

Good design: a clear title, fields in a sensible order, one font, readable size, labels lined up, and white space between groups.

e.g.Example
New booking form (top to bottom) Title: New Booking BookingID: [filled in by the system] MemberID: [drop-down of M01–M05] Activity: [drop-down] BookDate: [date box] Hours: [box] Paid: [check box]
!Watch out

Marks are lost for cramped forms, mixed fonts, labels cut off, or fields in a random order. Follow the order the task gives, and check every label is fully visible.

Study it

Open the study page and go one step at a time.

The steps for this lesson

Try it

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.