Normalization
Normalization
Nontrivial Dependencies
• Those FDs which are not trivial.
• Nontrivial FDs lead to definitions of integrity constraints like keys.
7. Normalization 02170 Database Systems 10
Functional Dependencies
Many functional dependencies can be proposed.
Example: Shipment1(Vendor, City, Part, Qty) (where a vendor only can be in one city)
No Determinant FD Dependent Validity Remark
1 {Vendor, Part} → {Qty} Legal
2 {Vendor} → {City} Legal
3 {Qty} → {Vendor} Illegal
4 {Part} → {Qty} Illegal
5 {Vendor, Part} → {City} Legal Derived(2)
• To decide whether a FD is valid (legal for all relation instances), one has to consider the real world.
• Of a set of 4 attributes, it is possible to make 24 = 16 subsets.
• Combining 16 determinants with 16 dependents gives 256 potential FDs.
• Of the 256 potential FDs, some are valid and some are not.
• (Canonical) Cover Set: A (irreducible/minimal) set of valid functional dependencies
from which all valid functional dependencies can be determined. In the example:
{ {Vendor, Part} → {Qty}, {Vendor} → {City}} is a canonical cover set.
• Closure Set F+ of a set F of functional dependencies: The set of all valid functional
dependencies that can be logically derived from the F.
Primary key
• A candidate key is selected by the DBA to be the primary key for a
relation.
OrdersTable(OrderNo, ItemNo)
Normalization to 1NF
Orders1NF(OrderNo, ItemNo)
Normalization to 3NF
• Customers3NF(CustomerNo, PostNo),
foreign key(PostNo) references Post(PostNo)
• Post(PostNo, CityName)
• Associated normalization of tables is
projections:
Orders2NF ≡ ∏OrderNo, ItemNo (Orders1NF)
Items ≡ ∏ItemNo, ItemName (Orders1NF)
• A Natural Join brings back the table:
Orders1NF ≡ Orders2NF |X| Items
• Normalization is information preserving .
7. Normalization 02170 Database Systems 25
Normal Forms 2NF-3NF, BCNF: General Definitions
• Are defined using the notion of functional dependencies.
• The original definitions (on previous slides) of 2NF-3NF assume the
tables have one candidate key which has been chosen as primary key.
• The generalized definitions of 2NF-3NF and BCNF (in the book) take
several candidate keys into account.
• When there is only one candidate key, the original and the generalized
definitions of 2NF-3NF are equivalent.
• When there is only one candidate key: 3NF and BCNF are the same.
• 3NF and BCNF are the same (according to Date) unless
• there are several composite candidate keys CK1 and CK2
• which are overlapping (CK1 ∩ CK2 ≠ {})
This exception is very rare.
67810324 28801713
7.1.2 Candidate Keys with Armstrong’s Rules 7.1.2 By using Armstrong’s rules:
Use Armstrong’s rules to make a list of 1. B → B by rule 4 Self-determination
Candidate Keys for the following relation 2. B → A by rule 5 Decomposition of B → AD
schema R(A, B, C, D) with the following 3. B → D by rule 5 Decomposition of B → AD
functional dependencies: 4. B → C given B → A ^ A → C by rule 3 Transitivity
5. B → ABCD by rule 6 Union
B → AD, D → B, A → C. Please specify which of
6. D → ABCD given D → B and B → ABCD by rule 3
Armstrong’s rules are used in each step. Candidate Keys are B and D!
Finally select a Primary Key. I select B to be the Primary Key, but I could have
selected D instead.