8.1.8 Produce and Check a Normalised Design
To design a normalised database, identify facts and dependencies, remove repeating groups, then remove partial and transitive dependencies while preserving links.
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. List facts before drawing tables
Read the scenario and write down every fact that must be retained. Identify which real-world item each fact describes. For an equipment rental, facts may describe a customer, an equipment item and a rental transaction.
2. Choose keys and record dependencies
Select identifiers and ask what each identifier determines. A RentalID may determine RentalDate and CustomerID. EquipmentID may determine EquipmentName. If a rental can contain several items, a line table can represent each rental-item pairing.
3. Apply the normal forms in order
First make each field hold one value (1NF). If a composite key exists, move attributes that depend on only part of it (2NF). Then move attributes that depend on another non-key field (3NF). Keep foreign keys so related records can still be connected.
4. Verify the final design
Each table should have an identifying key. Fields should be atomic. Non-key fields should depend on the whole key and not on another non-key field. Check that the foreign keys refer to existing primary keys and that the design still stores all facts required by the scenario.
Worked example
RentalLine(RentalID, ItemID, ItemName, RentalDate, DailyRate, Days). If RentalID and ItemID form the key: move RentalDate to Rental, ItemName to Item, and retain only fields that depend on the complete rental-item pairing in RentalLine. Confirm DailyRateβs determinant from the business rules before deciding its table.
Common mistake to avoid
Do not split tables just because values repeat. Explain the dependency and make sure the new tables still preserve every required relationship.
Interactive check
Choose an answer, read the explanation, and continue to the next example.
Independent practice
Try this original question before opening the suggested response.
A food-delivery system stores OrderID, CustomerID, CustomerEmail, MealID, MealName and Quantity. One order can include several meals. Propose tables and keys, stating assumptions. (6)
Suggested response
Customer(CustomerID PK, CustomerEmail); Meal(MealID PK, MealName); Order(OrderID PK, CustomerID FK); OrderLine(OrderID FK, MealID FK, Quantity), with composite key (OrderID, MealID) if a meal appears once per order. CustomerEmail depends on CustomerID, and MealName on MealID. Each order-item pairing has one row.
Answering clearly
Use the technical term, state what it does, and connect your explanation to the details in the question.