lecture 8 normalization
lecture 8 normalization
Database System Concepts - 7th Edition 7.2 ©Silberschatz, Korth and Sudarshan
Overview of Normalization
Database System Concepts - 7th Edition 7.3 ©Silberschatz, Korth and Sudarshan
Features of Good Relational Designs
▪ Suppose we combine instructor and department into in_dep, which represents the
natural join on the relations instructor and department
Database System Concepts - 7th Edition 7.4 ©Silberschatz, Korth and Sudarshan
A Combined Schema Without Repetition
Database System Concepts - 7th Edition 7.5 ©Silberschatz, Korth and Sudarshan
Decomposition
The problem arises when we have two employees with the same name
▪ The next slide shows how we lose information -- we cannot reconstruct the
original employee relation -- and so, this is a lossy decomposition.
Database System Concepts - 7th Edition 7.6 ©Silberschatz, Korth and Sudarshan
A Lossy Decomposition
Database System Concepts - 7th Edition 7.7 ©Silberschatz, Korth and Sudarshan
Lossless Decomposition
Database System Concepts - 7th Edition 7.8 ©Silberschatz, Korth and Sudarshan
Example of Lossless Decomposition
▪ Decomposition of R = (A, B, C)
R1 = (A, B) R2 = (B, C)
Database System Concepts - 7th Edition 7.9 ©Silberschatz, Korth and Sudarshan
Normalization Theory
Database System Concepts - 7th Edition 7.10 ©Silberschatz, Korth and Sudarshan
Functional Dependencies
▪ There are usually a variety of constraints (rules) on the data in the real world.
▪ For example, some of the constraints that are expected to hold in a university
database are:
• Students and instructors are uniquely identified by their ID.
• Each student and instructor has only one name.
• Each instructor and student is (primarily) associated with only one
department.
• Each department has only one value for its budget, and only one associated
building.
Database System Concepts - 7th Edition 7.11 ©Silberschatz, Korth and Sudarshan
Functional Dependencies (Cont.)
Database System Concepts - 7th Edition 7.12 ©Silberschatz, Korth and Sudarshan
Functional Dependencies Definition
▪ Let R be a relation schema
α ⊆ R and β ⊆ R
▪ The functional dependency
α→β
holds on R if and only if for any legal relations r(R), whenever any two tuples t1 and
t2 of r agree on the attributes α, they also agree on the attributes β. That is,
1 4
1 5
3 7
▪ On this instance, B → A hold; A → B does NOT hold,
Database System Concepts - 7th Edition 7.13 ©Silberschatz, Korth and Sudarshan
Closure of a Set of Functional Dependencies
▪ Given a set F set of functional dependencies, there are certain other functional
dependencies that are logically implied by F.
• If A → B and B → C, then we can infer that A → C
• etc.
▪ The set of all functional dependencies logically implied by F is the closure of F.
▪ We denote the closure of F by F+.
Database System Concepts - 7th Edition 7.14 ©Silberschatz, Korth and Sudarshan
Keys and Functional Dependencies
Database System Concepts - 7th Edition 7.15 ©Silberschatz, Korth and Sudarshan
Use of Functional Dependencies
Database System Concepts - 7th Edition 7.16 ©Silberschatz, Korth and Sudarshan
Trivial Functional Dependencies
Database System Concepts - 7th Edition 7.17 ©Silberschatz, Korth and Sudarshan
Lossless Decomposition
Database System Concepts - 7th Edition 7.18 ©Silberschatz, Korth and Sudarshan
Example
▪ R = (A, B, C)
F = {A → B, B → C)
▪ R1 = (A, B), R2 = (B, C)
• Lossless decomposition:
R1 ∩ R2 = {B} and B → BC
▪ R1 = (A, B), R2 = (A, C)
• Lossless decomposition:
R1 ∩ R2 = {A} and A → AB
▪ Note:
• B → BC
is a shorthand notation for
• B → {B, C}
Database System Concepts - 7th Edition 7.19 ©Silberschatz, Korth and Sudarshan
Dependency Preservation
Database System Concepts - 7th Edition 7.20 ©Silberschatz, Korth and Sudarshan
Dependency Preservation Example
▪ Consider a schema:
dept_advisor(s_ID, i_ID, department_name)
▪ With function dependencies:
i_ID → dept_name
s_ID, dept_name → i_ID
▪ In the above design we are forced to repeat the department name once for each
time an instructor participates in a dept_advisor relationship.
▪ To fix this, we need to decompose dept_advisor
▪ Any decomposition will not include all the attributes in
s_ID, dept_name → i_ID
▪ Thus, the composition NOT be dependency preserving
Database System Concepts - 7th Edition 7.21 ©Silberschatz, Korth and Sudarshan
Normal Forms
Database System Concepts - 7th Edition 7.22 ©Silberschatz, Korth and Sudarshan
Boyce-Codd Normal Form
Database System Concepts - 7th Edition 7.23 ©Silberschatz, Korth and Sudarshan
Boyce-Codd Normal Form (Cont.)
Database System Concepts - 7th Edition 7.24 ©Silberschatz, Korth and Sudarshan
Decomposing a Schema into BCNF
Database System Concepts - 7th Edition 7.25 ©Silberschatz, Korth and Sudarshan
Example
▪ R = (A, B, C)
F = {A → B, B → C)
▪ R1 = (A, B), R2 = (B, C)
• Lossless-join decomposition:
R1 ∩ R2 = {B} and B → BC
• Dependency preserving
▪ R1 = (A, B), R2 = (A, C)
• Lossless-join decomposition:
R1 ∩ R2 = {A} and A → AB
• Not dependency preserving
(cannot check B → C without computing R1 R2)
Database System Concepts - 7th Edition 7.26 ©Silberschatz, Korth and Sudarshan
BCNF and Dependency Preservation
Database System Concepts - 7th Edition 7.27 ©Silberschatz, Korth and Sudarshan
Third Normal Form
Database System Concepts - 7th Edition 7.28 ©Silberschatz, Korth and Sudarshan
3NF Example
▪ Consider a schema:
dept_advisor(s_ID, i_ID, dept_name)
▪ With function dependencies:
i_ID → dept_name
s_ID, dept_name → i_ID
▪ Two candidate keys = {s_ID, dept_name}, {s_ID, i_ID }
▪ We have seen before that dept_advisor is not in BCNF
▪ R, however, is in 3NF
• s_ID, dept_name is a superkey
• i_ID → dept_name and i_ID is NOT a superkey, but:
▪ { dept_name} – {i_ID } = {dept_name } and
▪ dept_name is contained in a candidate key
Database System Concepts - 7th Edition 7.29 ©Silberschatz, Korth and Sudarshan
Redundancy in 3NF
Database System Concepts - 7th Edition 7.30 ©Silberschatz, Korth and Sudarshan
Comparison of BCNF and 3NF
Database System Concepts - 7th Edition 7.31 ©Silberschatz, Korth and Sudarshan
Goals of Normalization
Database System Concepts - 7th Edition 7.32 ©Silberschatz, Korth and Sudarshan
How good is BCNF?
Database System Concepts - 7th Edition 7.33 ©Silberschatz, Korth and Sudarshan
How good is BCNF? (Cont.)
Database System Concepts - 7th Edition 7.34 ©Silberschatz, Korth and Sudarshan
Higher Normal Forms
• inst_phone:
▪ This suggests the need for higher normal forms, such as Fourth Normal Form
(4NF), which we shall see later
Database System Concepts - 7th Edition 7.35 ©Silberschatz, Korth and Sudarshan
Functional-Dependency Theory
Database System Concepts - 7th Edition 7.36 ©Silberschatz, Korth and Sudarshan
Functional-Dependency Theory Roadmap
▪ We now consider the formal theory that tells us which functional dependencies
are implied logically by a given set of functional dependencies.
▪ We then develop algorithms to generate lossless decompositions into BCNF and
3NF
▪ We then develop algorithms to test if a decomposition is dependency-preserving
Database System Concepts - 7th Edition 7.37 ©Silberschatz, Korth and Sudarshan
Closure of a Set of Functional Dependencies
▪ Given a set F set of functional dependencies, there are certain other functional
dependencies that are logically implied by F.
• If A → B and B → C, then we can infer that A → C
• etc.
▪ The set of all functional dependencies logically implied by F is the closure of F.
▪ We denote the closure of F by F+.
Database System Concepts - 7th Edition 7.38 ©Silberschatz, Korth and Sudarshan
Closure of a Set of Functional Dependencies
Database System Concepts - 7th Edition 7.39 ©Silberschatz, Korth and Sudarshan
Example of F+
▪ R = (A, B, C, G, H, I)
F={A→B
A→C
CG → H
CG → I
B → H}
▪ Some members of F+
• A→H
▪ by transitivity from A → B and B → H
• AG → I
▪ by augmenting A → C with G, to get AG → CG
and then transitivity with CG → I
• CG → HI
▪ by augmenting CG → I to infer CG → CGI,
and augmenting of CG → H to infer CGI → HI,
and then transitivity
Database System Concepts - 7th Edition 7.40 ©Silberschatz, Korth and Sudarshan
Closure of Functional Dependencies (Cont.)
▪ Additional rules:
• Union rule: If α → β holds and α → γ holds, then α → β γ holds.
• Decomposition rule: If α → β γ holds, then α → β holds and α → γ
holds.
• Pseudotransitivity rule:If α → β holds and γ β → δ holds, then α γ → δ
holds.
▪ The above rules can be inferred from Armstrong’s axioms.
Database System Concepts - 7th Edition 7.41 ©Silberschatz, Korth and Sudarshan
Procedure for Computing F+
Database System Concepts - 7th Edition 7.42 ©Silberschatz, Korth and Sudarshan
Closure of Attribute Sets
▪ Given a set of attributes α, define the closure of α under F (denoted by α+) as the
set of attributes that are functionally determined by α under F
▪ Algorithm to compute α+, the closure of α under F
result := α;
while (changes to result) do
for each β → γ in F do
begin
if β ⊆ result then result := result ∪ γ
end
Database System Concepts - 7th Edition 7.43 ©Silberschatz, Korth and Sudarshan
Example of Attribute Set Closure
▪ R = (A, B, C, G, H, I)
▪ F = {A → B
A→C
CG → H
CG → I
B → H}
▪ (AG)+
1. result = AG
2. result = ABCG (A → C and A → B)
3. result = ABCGH (CG → H and CG ⊆ AGBC)
4. result = ABCGHI (CG → I and CG ⊆ AGBCH)
▪ Is AG a candidate key?
1. Is AG a super key?
1. Does AG → R? == Is R ⊇ (AG)+
2. Is any subset of AG a superkey?
1. Does A → R? == Is R ⊇ (A)+
2. Does G → R? == Is R ⊇ (G)+
3. In general: check for each subset of size n-1
Database System Concepts - 7th Edition 7.44 ©Silberschatz, Korth and Sudarshan
Uses of Attribute Closure
There are several uses of the attribute closure algorithm:
▪ Testing for superkey:
• To test if α is a superkey, we compute α+, and check if α+ contains all
attributes of R.
▪ Testing functional dependencies
• To check if a functional dependency α → β holds (or, in other words, is in
F+), just check if β ⊆ α+.
• That is, we compute α+ by using attribute closure, and then check if it
contains β.
• Is a simple and cheap test, and very useful
▪ Computing closure of F
• For each γ ⊆ R, we find the closure γ+, and for each S ⊆ γ+, we output a
functional dependency γ → S.
Database System Concepts - 7th Edition 7.45 ©Silberschatz, Korth and Sudarshan
Canonical Cover
Database System Concepts - 7th Edition 7.46 ©Silberschatz, Korth and Sudarshan
Extraneous Attributes
▪ Removing an attribute from the left side of a functional dependency could make
it a stronger constraint.
• For example, if we have AB → C and remove B, we get the possibly
stronger result A → C. It may be stronger because A → C logically
implies AB → C, but AB → C does not, on its own, logically imply A → C
▪ But, depending on what our set F of functional dependencies happens to be, we
may be able to remove B from AB → C safely.
• For example, suppose that
• F = {AB → C, A → D, D → C}
• Then we can show that F logically implies A → C, making extraneous in AB
→ C.
Database System Concepts - 7th Edition 7.47 ©Silberschatz, Korth and Sudarshan
Extraneous Attributes (Cont.)
▪ Removing an attribute from the right side of a functional dependency could make
it a weaker constraint.
• For example, if we have AB → CD and remove C, we get the possibly
weaker result AB → D. It may be weaker because using just AB → D, we
can no longer infer AB → C.
▪ But, depending on what our set F of functional dependencies happens to be, we
may be able to remove C from AB → CD safely.
• For example, suppose that
F = { AB → CD, A → C.
• Then we can show that even after replacing AB → CD by AB → D, we can
still infer $AB → C and thus AB → CD.
Database System Concepts - 7th Edition 7.48 ©Silberschatz, Korth and Sudarshan
Extraneous Attributes
Database System Concepts - 7th Edition 7.49 ©Silberschatz, Korth and Sudarshan
Testing if an Attribute is Extraneous
Database System Concepts - 7th Edition 7.50 ©Silberschatz, Korth and Sudarshan
Examples of Extraneous Attributes
Database System Concepts - 7th Edition 7.51 ©Silberschatz, Korth and Sudarshan
Canonical Cover
Database System Concepts - 7th Edition 7.52 ©Silberschatz, Korth and Sudarshan
Canonical Cover
▪ Note: Union rule may become applicable after some extraneous attributes have
been deleted, so it has to be re-applied
Database System Concepts - 7th Edition 7.53 ©Silberschatz, Korth and Sudarshan
Example: Computing a Canonical Cover
▪ R = (A, B, C)
F = {A → BC
B→C
A→B
AB → C}
▪ Combine A → BC and A → B into A → BC
• Set is now {A → BC, B → C, AB → C}
▪ A is extraneous in AB → C
• Check if the result of deleting A from AB → C is implied by the other
dependencies
▪ Yes: in fact, B → C is already present!
• Set is now {A → BC, B → C}
▪ C is extraneous in A → BC
• Check if A → C is logically implied by A → B and the other dependencies
▪ Yes: using transitivity on A → B and B → C.
• Can use attribute closure of A in more complex cases
▪ The canonical cover is: A → B
B→C
Database System Concepts - 7th Edition 7.54 ©Silberschatz, Korth and Sudarshan
Dependency Preservation
Database System Concepts - 7th Edition 7.55 ©Silberschatz, Korth and Sudarshan
Dependency Preservation (Cont.)
Database System Concepts - 7th Edition 7.56 ©Silberschatz, Korth and Sudarshan
Testing for Dependency Preservation
Database System Concepts - 7th Edition 7.57 ©Silberschatz, Korth and Sudarshan
Example
▪ R = (A, B, C )
F = {A → B
B → C}
Key = {A}
▪ R is not in BCNF
▪ Decomposition R1 = (A, B), R2 = (B, C)
• R1 and R2 in BCNF
• Lossless-join decomposition
• Dependency preserving
Database System Concepts - 7th Edition 7.58 ©Silberschatz, Korth and Sudarshan
Algorithm for Decomposition Using
Functional Dependencies
Database System Concepts - 7th Edition 7.59 ©Silberschatz, Korth and Sudarshan
Testing for BCNF
Database System Concepts - 7th Edition 7.60 ©Silberschatz, Korth and Sudarshan
Testing Decomposition for BCNF
▪ Either test Ri for BCNF with respect to the restriction of F+ to Ri (that is, all
FDs in F+ that contain only attributes from Ri)
▪ Or use the original set of dependencies F that hold on R, but with the
following test:
▪ for every set of attributes α ⊆ Ri, check that α+ (the attribute closure
of α) either includes no attribute of Ri- α, or includes all attributes of
Ri.
• If the condition is violated by some α → β in F+, the dependency
α → (α+ - α) ∩ Ri
can be shown to hold on Ri, and Ri violates BCNF.
• We use above dependency to decompose Ri
Database System Concepts - 7th Edition 7.61 ©Silberschatz, Korth and Sudarshan
BCNF Decomposition Algorithm
result := {R };
done := false;
compute F +;
while (not done) do
if (there is a schema Ri in result that is not in BCNF)
then begin
let α → β be a nontrivial functional dependency that
holds on Ri such that α → Ri is not in F +,
and α ∩ β = ∅;
result := (result – Ri ) ∪ (Ri – β) ∪ (α, β );
end
else done := true;
Database System Concepts - 7th Edition 7.62 ©Silberschatz, Korth and Sudarshan
Example of BCNF Decomposition
Database System Concepts - 7th Edition 7.63 ©Silberschatz, Korth and Sudarshan
BCNF Decomposition (Cont.)
▪ course is in BCNF
• How do we know this?
▪ building, room_number→capacity holds on class-1
• but {building, room_number} is not a superkey for class-1.
• We replace class-1 by:
▪ classroom (building, room_number, capacity)
▪ section (course_id, sec_id, semester, year, building, room_number,
time_slot_id)
▪ classroom and section are in BCNF.
Database System Concepts - 7th Edition 7.64 ©Silberschatz, Korth and Sudarshan
Third Normal Form
Database System Concepts - 7th Edition 7.65 ©Silberschatz, Korth and Sudarshan
3NF Example -- Relation dept_advisor
Database System Concepts - 7th Edition 7.66 ©Silberschatz, Korth and Sudarshan
Testing for 3NF
▪ Need to check only FDs in F, need not check all FDs in F+.
▪ Use attribute closure to check for each dependency α → β, if α is a superkey.
▪ If α is not a superkey, we have to verify if each attribute in β is contained in a
candidate key of R
• This test is rather more expensive, since it involve finding candidate keys
• Testing for 3NF has been shown to be NP-hard
• Interestingly, decomposition into third normal form (described shortly) can
be done in polynomial time
Database System Concepts - 7th Edition 7.67 ©Silberschatz, Korth and Sudarshan
3NF Decomposition Algorithm
Database System Concepts - 7th Edition 7.69 ©Silberschatz, Korth and Sudarshan
3NF Decomposition: An Example
▪ Relation schema:
cust_banker_branch = (customer_id, employee_id, branch_name, type )
▪ The functional dependencies for this relation schema are:
• customer_id, employee_id → branch_name, type
• employee_id → branch_name
• customer_id, branch_name → employee_id
▪ We first compute a canonical cover
• branch_name is extraneous in the r.h.s. of the 1st dependency
• No other attribute is extraneous, so we get FC =
customer_id, employee_id → type
employee_id → branch_name
customer_id, branch_name → employee_id
Database System Concepts - 7th Edition 7.70 ©Silberschatz, Korth and Sudarshan
3NF Decompsition Example (Cont.)
Database System Concepts - 7th Edition 7.71 ©Silberschatz, Korth and Sudarshan
Comparison of BCNF and 3NF
Database System Concepts - 7th Edition 7.72 ©Silberschatz, Korth and Sudarshan
Design Goals
Database System Concepts - 7th Edition 7.73 ©Silberschatz, Korth and Sudarshan
Multivalued Dependencies
Database System Concepts - 7th Edition 7.74 ©Silberschatz, Korth and Sudarshan
Multivalued Dependencies (MVDs)
Database System Concepts - 7th Edition 7.75 ©Silberschatz, Korth and Sudarshan
Multivalued Dependencies
Database System Concepts - 7th Edition 7.76 ©Silberschatz, Korth and Sudarshan
MVD -- Tabular representation
▪ Tabular representation of α →→ β
Database System Concepts - 7th Edition 7.77 ©Silberschatz, Korth and Sudarshan
MVD (Cont.)
▪ Let R be a relation schema with a set of attributes that are partitioned into 3
nonempty subsets.
Y, Z, W
▪ We say that Y →→ Z (Y multidetermines Z )
if and only if for all possible relations r (R )
< y1, z1, w1 > ∈ r and < y1, z2, w2 > ∈ r
then
< y1, z1, w2 > ∈ r and < y1, z2, w1 > ∈ r
▪ Note that since the behavior of Z and W are identical it follows that
Y →→ Z if Y →→ W
Database System Concepts - 7th Edition 7.78 ©Silberschatz, Korth and Sudarshan
Example
▪ In our example:
ID →→ child_name
ID →→ phone_number
▪ The above formal definition is supposed to formalize the notion that given a
particular value of Y (ID) it has associated with it a set of values of Z
(child_name) and a set of values of W (phone_number), and these two sets are in
some sense independent of each other.
▪ Note:
• If Y → Z then Y →→ Z
• Indeed we have (in above notation) Z1 = Z2
The claim follows.
Database System Concepts - 7th Edition 7.79 ©Silberschatz, Korth and Sudarshan
Use of Multivalued Dependencies
Database System Concepts - 7th Edition 7.80 ©Silberschatz, Korth and Sudarshan
Theory of MVDs
▪ From the definition of multivalued dependency, we can derive the following rule:
• If α → β, then α →→ β
That is, every functional dependency is also a multivalued dependency
▪ The closure D+ of D is the set of all functional and multivalued dependencies
logically implied by D.
• We can compute D+ from D, using the formal definitions of functional
dependencies and multivalued dependencies.
• We can manage with such reasoning for very simple multivalued
dependencies, which seem to be most common in practice
• For complex dependencies, it is better to reason about sets of dependencies
using a system of inference rules (Appendix C).
Database System Concepts - 7th Edition 7.81 ©Silberschatz, Korth and Sudarshan
Fourth Normal Form
Database System Concepts - 7th Edition 7.82 ©Silberschatz, Korth and Sudarshan
Restriction of Multivalued Dependencies
Database System Concepts - 7th Edition 7.83 ©Silberschatz, Korth and Sudarshan
4NF Decomposition Algorithm
result: = {R};
done := false;
compute D+;
Let Di denote the restriction of D+ to Ri
while (not done)
if (there is a schema Ri in result that is not in 4NF) then
begin
let α →→ β be a nontrivial multivalued dependency that holds
on Ri such that α → Ri is not in Di, and α∩β=φ;
result := (result - Ri) ∪ (Ri - β) ∪ (α, β);
end
else done:= true;
Note: each Ri is in 4NF, and decomposition is lossless-join
Database System Concepts - 7th Edition 7.84 ©Silberschatz, Korth and Sudarshan
Example
▪ R =(A, B, C, G, H, I)
F ={ A →→ B
B →→ HI
CG →→ H }
▪ R is not in 4NF since A →→ B and A is not a superkey for R
▪ Decomposition
a) R1 = (A, B) (R1 is in 4NF)
b) R2 = (A, C, G, H, I) (R2 is not in 4NF, decompose into R3 and R4)
c) R3 = (C, G, H) (R3 is in 4NF)
d) R4 = (A, C, G, I) (R4 is not in 4NF, decompose into R5 and R6)
• A →→ B and B →→ HI A →→ HI, (MVD transitivity), and
• and hence A →→ I (MVD restriction to R4)
e) R5 = (A, I) (R5 is in 4NF)
f)R6 = (A, C, G) (R6 is in 4NF)
Database System Concepts - 7th Edition 7.85 ©Silberschatz, Korth and Sudarshan
Additional issues
Database System Concepts - 7th Edition 7.86 ©Silberschatz, Korth and Sudarshan
Further Normal Forms
Database System Concepts - 7th Edition 7.87 ©Silberschatz, Korth and Sudarshan
Overall Database Design Process
Database System Concepts - 7th Edition 7.88 ©Silberschatz, Korth and Sudarshan
ER Model and Normalization
▪ When an E-R diagram is carefully designed, identifying all entities correctly, the
tables generated from the E-R diagram should not need further normalization.
▪ However, in a real (imperfect) design, there can be functional dependencies from
non-key attributes of an entity to other attributes of the entity
• Example: an employee entity with
▪ attributes
department_name and building,
▪ functional dependency
department_name→ building
▪ Good design would have made department an entity
▪ Functional dependencies from non-key attributes of a relationship set possible, but
rare --- most relationships are binary
Database System Concepts - 7th Edition 7.89 ©Silberschatz, Korth and Sudarshan
Denormalization for Performance
Database System Concepts - 7th Edition 7.90 ©Silberschatz, Korth and Sudarshan
Other Design Issues
Database System Concepts - 7th Edition 7.91 ©Silberschatz, Korth and Sudarshan
Modeling Temporal Data
▪ Temporal data have an association time interval during which the data are valid.
▪ A snapshot is the value of the data at a particular point in time
▪ Several proposals to extend ER model by adding valid time to
• attributes, e.g., address of an instructor at different points in time
• entities, e.g., time duration when a student entity exists
• relationships, e.g., time during which an instructor was associated with a
student as an advisor.
▪ But no accepted standard
▪ Adding a temporal component results in functional dependencies like
ID → street, city
not holding, because the address varies over time
▪ A temporal functional dependency X → Y holds on schema R if the functional
dependency X Y holds on all snapshots for all legal instances r (R).
Database System Concepts - 7th Edition 7.92 ©Silberschatz, Korth and Sudarshan
Modeling Temporal Data (Cont.)
▪ In practice, database designers may add start and end time attributes to relations
• E.g., course(course_id, course_title) is replaced by
course(course_id, course_title, start, end)
• Constraint: no two tuples can have overlapping valid times
▪ Hard to enforce efficiently
▪ Foreign key references may be to current version of data, or to data at a point in
time
• E.g., student transcript should refer to course information at the time the
course was taken
Database System Concepts - 7th Edition 7.93 ©Silberschatz, Korth and Sudarshan
End of Chapter 7
Database System Concepts - 7th Edition 7.94 ©Silberschatz, Korth and Sudarshan
Proof of Correctness of 3NF
Decomposition Algorithm
Database System Concepts - 7th Edition 7.95 ©Silberschatz, Korth and Sudarshan
Correctness of 3NF Decomposition Algorithm
Database System Concepts - 7th Edition 7.96 ©Silberschatz, Korth and Sudarshan
Correctness of 3NF Decomposition Algorithm (Cont.)
Database System Concepts - 7th Edition 7.97 ©Silberschatz, Korth and Sudarshan
Correctness of 3NF Decomposition (Cont.)
▪ Case 1: If B in β:
• If γ is a superkey, the 2nd condition of 3NF is satisfied
• Otherwise α must contain some attribute not in γ
• Since γ → B is in F+ it must be derivable from Fc, by using attribute closure
on γ.
• Attribute closure not have used α →β. If it had been used, α must be
contained in the attribute closure of γ, which is not possible, since we
assumed γ is not a superkey.
• Now, using α→ (β- {B}) and γ → B, we can derive α →B
(since γ ⊆ α β, and B ∉ γ since γ → B is non-trivial)
• Then, B is extraneous in the right-hand side of α →β; which is not possible
since α →β is in Fc.
• Thus, if B is in β then γ must be a superkey, and the second condition of
3NF must be satisfied.
Database System Concepts - 7th Edition 7.98 ©Silberschatz, Korth and Sudarshan
Correctness of 3NF Decomposition (Cont.)
▪ Case 2: B is in α.
• Since α is a candidate key, the third alternative in the definition of 3NF is
trivially satisfied.
• In fact, we cannot show that γ is a superkey.
• This shows exactly why the third alternative is present in the definition of
3NF.
Q.E.D.
Database System Concepts - 7th Edition 7.99 ©Silberschatz, Korth and Sudarshan
First Normal Form
Database System Concepts - 7th Edition 7.10 ©Silberschatz, Korth and Sudarshan
First Normal Form (Cont.)
▪ Atomicity is actually a property of how the elements of the domain are used.
• Example: Strings would normally be considered indivisible
• Suppose that students are given roll numbers which are strings of the form
CS0012 or EE1127
• If the first two characters are extracted to find the department, the domain of
roll numbers is not atomic.
• Doing so is a bad idea: leads to encoding of information in application
program rather than in the database.
Database System Concepts - 7th Edition 7.10 ©Silberschatz, Korth and Sudarshan