FutureLogic Blog → Databases → IGCSE 0478

What Is Database Structure?
Explained Simply

A database table stores data in rows and columns. Each row is a record holding all data about one item, each column is a field storing one category of data, and a primary key is a unique field that identifies every record.

Watch the Golden Biscuit Tin's paper order list become a BiscuitOrders table, then learn how to spot records, fields and values, choose data types and justify a primary key for Cambridge IGCSE Computer Science (0478).

FutureLogic Education thumbnail: Database Structure – Fields, Records and Primary Keys, with Jacques the pigeon, a chicken and a pirate parrot opening a card-index box next to the Golden Biscuit Tin

From an order list to a database table

At the Golden Biscuit Tin, Jacques writes every biscuit order on a paper slip. Each slip shows an order number, the type of biscuit and how many were ordered. That works for four orders. It stops working when there are four hundred and someone asks, “Which orders were for Hobnobs?”

A database solves this by storing the same data in a table. Because every order is stored in the same layout, the data can be searched, sorted and totalled quickly.

A table is a grid. Each row is one record. Each column is one field.

Cambridge syllabus focus

Topic 9.1: define a single-table database using fields and records, suggest suitable basic data types, and understand the purpose of a primary key so you can identify a suitable one.

Turning the order list into a table

Every order becomes one row of the BiscuitOrders table. Each piece of information on the slip, such as the order number, gets its own named column.

Paper order list becomes a database tableFour handwritten biscuit orders on the left are rearranged into the BiscuitOrders table on the right, with fields OrderID, BiscuitType and Quantity and one row per order. PAPER ORDER LIST #101 · Hobnob × 6 #102 · Viennese Swirl × 4 #103 · Hobnob × 8 #104 · Hobnob × 2 → BiscuitOrders TABLE OrderIDBiscuitTypeQuantity 101Hobnob6102Viennese Swirl4103Hobnob8104Hobnob2 Same data, now organised: 4 records (rows) × 3 fields (columns)
Diagram 1: Each order slip becomes one record. Each piece of information on the slip becomes a field.

Records, fields and values

The table below highlights one record, one field and one individual value. Learn the difference between these three words, because exam questions test it again and again.

Record: order 102Field: BiscuitTypeValue: 8
BiscuitOrders table
OrderIDBiscuitTypeQuantity
101Hobnob6
102Viennese Swirl4
103Hobnob8
104Hobnob2
  • Record – one complete row holding all the data about one order. Record 102 is 102, Viennese Swirl, 4.
  • Field – one column holding one category of data for every record. BiscuitType is a field.
  • Value – a single item of data where one record meets one field. Order 103's Quantity value is 8.

Check your understanding 1

How many records and how many fields does BiscuitOrders contain?

Reveal answer

4 records (one row per order) and 3 fields (OrderID, BiscuitType and Quantity). The heading row holds the field names. It is not a record.

Why OrderID is the primary key

A primary key is a field whose value is unique for every record, so it can identify exactly one record. In BiscuitOrders, the OrderID values are 101, 102, 103 and 104. No two orders share one, and every new order is given a new number. Tell the database “order 103” and it finds exactly one record.

BiscuitType cannot be the primary key, because Hobnob appears in three different records. Searching for “Hobnob” finds three orders, not one. Repeated values are normal in a field like this, because many customers order the same biscuit.

Quantity is not suitable either. The four values (6, 4, 8 and 2) happen to be different today, but nothing stops two future orders from both being for 6 biscuits.

Exam tip: To justify a primary key, say that its value is unique for each record and that it therefore identifies one record. “It is a number” or “it comes first” will not earn the mark.

Choosing suitable data types

Each field stores one type of data. The basic data types for Cambridge 0478 are text/alphanumeric, character, Boolean, integer, real and date/time.

Suggested data types for BiscuitOrders
FieldExample valueData typeReason
OrderID101IntegerA whole-number code that identifies each order
BiscuitTypeViennese SwirlText / AlphanumericLetters and spaces
Quantity4IntegerA whole number of biscuits that can be used in calculations
Exam habit: In database questions, write Text or Alphanumeric rather than the programming word String. Real would be a poor choice for Quantity, because nobody orders half a Hobnob.

Worked example: adding a new order

A fifth order arrives for 5 Viennese Swirls. What changes in the table?

  1. A new record is added: 105, Viennese Swirl, 5.
  2. The number of fields stays at 3. A new order needs a new row, not a new column.
  3. The number of records rises to 5.
  4. The new OrderID, 105, has not been used before. Giving this order the ID 101 again would break the primary key, because 101 would no longer identify one order.

Result: new data means new records. The structure (the fields) only changes if the business wants to store a new kind of information, such as an order date.

Check your understanding 2

The Quantity values 6, 4, 8 and 2 are all different. Why is Quantity still not a suitable primary key?

Reveal answer

A primary key must be unique for every record that will ever be stored. Two future orders could easily have the same quantity, so Quantity cannot be relied on to identify one record.

Common Cambridge exam mistakes

✗ “BiscuitType is the primary key because it describes the order.”

A primary key must be unique. Hobnob appears in three records, so BiscuitType cannot identify a single order. OrderID can.

✗ “The table has 3 records and 4 fields.”

This swaps rows and columns. Records are rows (there are 4) and fields are columns (there are 3). Do not count the heading row as a record.

Original FutureLogic exam-style practice

These are original teaching questions, not official Cambridge examination questions. The marks shown are a guide only.

Question 1 (2 marks)

Using the BiscuitOrders table, state a suitable data type for the BiscuitType field and for the Quantity field.

Reveal model answer

BiscuitType: Text / Alphanumeric (1)
Quantity: Integer (1)

Question 2 (3 marks)

Identify the most suitable primary key for the BiscuitOrders table. Justify your choice.

Reveal model answer

OrderID (1). Each OrderID value is unique, so no two orders share the same value (1). It can therefore identify exactly one record/order (1).

Also creditworthy: BiscuitType is unsuitable because values such as Hobnob are repeated.

Quick quiz

  1. What is a record?
  2. What is a field?
  3. Which field in BiscuitOrders is the primary key?
  4. What data type suits the Quantity field?

Quiz answers

Reveal all answers
  1. One row of a table, holding all the data about one item (here, one order).
  2. One column of a table, holding one category of data for every record.
  3. OrderID.
  4. Integer.

Final summary

Record

One row: all the data about one order.

Field

One column: one category of data, such as BiscuitType.

Primary key

A unique value that identifies each record: OrderID.

Data types

Integer, Text and Integer for the three fields.

Rows are records, columns are fields, and the primary key is the field whose values never repeat.

Ready to query the Golden Biscuit Tin?

Now that you can read the BiscuitOrders table, learn how SQL chooses, filters, totals and counts its records.