Chapter 14
Chapter 14
spurious tuples
Semantics of the Relation Attributes
❑GUIDELINE 1:
− Each tuple in a relation should represent one
entity or relationship instance.
− Attributes of different entities should not be
mixed in the same relation.
− Only foreign keys should be used to refer to
other entities
− Entity and relationship attributes should be kept
apart as much as possible.
Semantics of the Relation Attributes
❑Example:
Redundant Information in Tuples and
Update Anomalies
❑Mixing attributes of multiple entities may cause
problems
❑Information is stored redundantly wasting storage
❑Problems with update anomalies
Insertion anomalies
Deletion anomalies
Modification anomalies
Redundant Information in Tuples and
Update Anomalies
Redundant Information in Tuples and
Update Anomalies
❑Consider the relation:
EMP_PROJ ( Emp#, Proj#, Ename, Pname, No_hours)
❑Update Anomaly: Changing the name of project
number P1 from “Billing” to “Customer-
Accounting” may cause this update to be made for
all 100 employees working on project P1.
❑Insert Anomaly: Cannot insert a project unless
an employee is assigned to .
❑Inversely - Cannot insert an employee unless an
he/she is assigned to a project
Redundant Information in Tuples and
Update Anomalies
❑Delete Anomaly: When a project is deleted, it will
result in deleting all the employees who work on
that project. Alternately, if an employee is the sole
employee on a project, deleting that employee
would result in deleting the corresponding project
Redundant Information in Tuples and
Update Anomalies
❑GUIDELINE 2: Guideline to Redundant
Information in Tuples and Update Anomalies
Design the base relation schemas so that no
insertion, deletion, or modification anomalies
are present in the relations.
If any anomalies are present, note them clearly
and make sure that the programs that update the
database will operate correctly.
Null Values in Tuples
GUIDELINE 3: Relations should be designed such
that their tuples will have as few NULL values as
possible
❑Attributes that are NULL frequently could be
placed in separate relations
❑ Reasons for nulls:
Attribute not applicable or invalid
Attribute value unknown (may exist)
Value known to exist, but unavailable
Spurious Tuples
❑Bad designs for a relational database may result in
erroneous results for certain JOIN operations
❑The "lossless join" property is used to guarantee
meaningful results for join operations
S1 London P1 100
S1 London P2 100
S2 Paris P1 200
S2 Paris P2 200
S3 Delhi P2 300
S4 Kolkata P2 400
S4 Kolkata P2 400
S4 Kolkata P5 400
Example (SCP Relation) (contd..)
One FD : - ( { S#} → {City})
❑{Plane}→ StartTime
❑{Pilot, StartDate, StartTime}→ Plane
❑{Plane, StartDate}→ Pilot
Functional dependencies
❑A functional dependency is a constraint between
two sets of attributes from the database. Suppose
that relational database schema has n attributes
R{A1, A2, … An}, X and Y are subset of R.
❑Definition.
A functional dependency between two sets of
attributes X and Y: X→Y, specifies a constraint on
the possible tuples that can form a relation state
r of R.
The constraint is that, for any two tuples t1 and
t2 in r that have t1[X]=t2[X]➔ t1[Y] = t2[Y] .
Functional Dependency
❑Main concept associated with normalization.
❑Functional Dependency
Describes relationship between attributes in a
relation.
If A and B are attributes of relation R, B is
functionally dependent on A (denoted A → B), if each
value of A in R is associated with exactly one value of
B in R.
Functional Dependency
❑Property of the meaning (or semantics) of the
attributes in a relation.
❑Diagrammatic representation:
R1 (A, B, D)
R2 (B,C)
Third Normal Form
❑Third normal form (3NF) is based on the
concept of transitive dependency.
❑Transitive functional dependency A functional
dependency X→Z that can be derived from two
FDs X →Y and Y→ Z
❑Examples:
SSN → DMGRSSN is a transitive FD since
SSN→DNUMBER and DNUMBER →DMGRSSN hold
3NF Normal Form
❑Let Say you have Relation R(A, B, C, D)
With functional Dependencies
A→B
A→C
C→D
R1 (A, B, C)
R2 (C, D)
Example
❑ Let Say you have Relation R(A, B, C, D, E, F)
AB→CDEF
A→F
D→E
2NF:
R1 (A, B, C, D, E)
R2 (A, F)
3NF:
R1 (A, B, C, D)
R2 (A, F)
R3 (D, E)
BCNF (Boyce-Codd Normal Form)
❑Boyce-Codd normal form (BCNF) was proposed as
a simpler form of 3NF, but it was found to be
stricter than 3NF. That is, every relation in BCNF is
also in 3NF; however, a relation in 3NF is not
necessarily in BCNF.
❑Definition. A relation schema R is in BCNF if
whenever a nontrivial functional dependency
X→A holds in R, then X is a candidate key of R
BCNF (Boyce-Codd Normal Form)
❑Each normal form is strictly stronger than the
previous one
Every 2NF relation is in 1NF
Every 3NF relation is in 2NF
Every BCNF relation is in 3NF
❑There exist relations that are in 3NF but not in
BCNF The goal is to have each relation in BCNF (or
3NF)