A-Level Computer Science / Unit 8: Relational Databases and SQL

8.1.6 Normalisation: Second Normal Form

πŸ”’ Lesson slides are available to signed-in users. Sign in

8.1.6 Normalisation: Second Normal Form

Second Normal Form (2NF) requires 1NF and removes partial dependencies on part of a composite key.

By the end of this page, you should be able to:

  • define and use the key terms accurately;
  • explain how the idea works using a new example;
  • apply the idea to a database design or SQL task.

1. Start with a composite key

A composite key contains more than one field. In BookingItem(BookingID, ItemID, ItemName, Quantity), the pair (BookingID, ItemID) may identify one line. BookingID alone can identify a booking, but not a particular item line.

2. Depend on the whole key

For 2NF, each non-key field must depend on the whole candidate key. Quantity can depend on both BookingID and ItemID because it describes that item within that booking. ItemName depends only on ItemID.

3. Identify a partial dependency

A partial dependency occurs when a non-key field depends on only one part of a composite key. ItemName is repeated each time the same item appears on another booking line. That repetition can create update problems.

4. Move the fact to its determinant

Store ItemName in Item(ItemID, ItemName). Keep ItemID in BookingItem as a foreign key. BookingItem can then store the pairing-specific quantity without repeating the item’s name.

Worked example

BookingItem(BookingID, ItemID, ItemName, Quantity), key (BookingID, ItemID). Split into Item(ItemID PK, ItemName) and BookingItem(BookingID, ItemID, Quantity), where the pair remains the key.

Common mistake to avoid

2NF matters when a key is composite. State which non-key field depends on which part; merely spotting repetition does not explain a partial dependency.

Interactive check

Choose an answer, read the explanation, and continue to the next example.

Try it

Check your understanding

Question 1 of 3
Score: 0 / 3

Independent practice

Try this original question before opening the suggested response.

A table with key (TripID, GuideID) also stores GuidePhone. GuidePhone depends only on GuideID. Explain the 2NF problem and a repair. (4)

Suggested response

GuidePhone depends on GuideID alone, which is only part of the composite key (TripID, GuideID). This is a partial dependency, so the table is not in 2NF. Store GuidePhone in Guide(GuideID, GuidePhone) and keep GuideID in the trip-guide table.

Answering clearly

Use the technical term, state what it does, and connect your explanation to the details in the question.