AeroLab Reading room

CS / AS level

Relational databases and normalisation

Relations connect records using primary and foreign keys. Entity relationships and normalisation reduce anomalies by assigning facts to appropriate tables.

Learning objectives

The big idea

Relations connect records using primary and foreign keys. Entity relationships and normalisation reduce anomalies by assigning facts to appropriate tables.

SQL selects, joins, groups and aggregates records. Distinguish filtering individual rows with WHERE from filtering aggregated groups with HAVING; a join needs a meaningful relationship condition.

Worked example

Orders.customer_id references Customers.id. Which is the foreign key?

Follow the solution

It links an order to a customer’s primary key.

Investigate and explain

Predict the worked result before calculating. Change one input, record the new result, and explain which assumptions still hold.

Use the prediction activity below; a local model appears only where it supports this topic.

Open the interactive investigation

Check your understanding

1. What problem can duplicated customer addresses create?

  1. Guaranteed faster correctness
  2. Automatic encryption
  3. Update anomalies
Check the answer and reasoning

Update anomalies

Updating one copy but not another can leave contradictory facts.

2. Orders.customer_id references Customers.id. Which is the foreign key?

  1. Orders.customer_id
  2. Customers.name
  3. Orders.total always
Check the answer and reasoning

Orders.customer_id

It links an order to a customer’s primary key.

3. Does normalisation mean deleting all repeated values?

  1. Yes
  2. No
  3. Only in SQL
Check the answer and reasoning

No

It organises dependencies; repeated foreign-key values may correctly represent many related records.