Download presentation
Presentation is loading. Please wait.
Published byShanna King Modified over 6 years ago
1
Normal forms First Normal Form (1NF) Second Normal Form (2NF)
Third Normal Form (3NF) Boyce/Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF)
2
First normal form (1NF) The only attribute values permitted are single atomic (indivisible) Not allow a set, list, bag, etc. considered to be part of the formal definition of a relations
3
Various functional dependencies
Prime and nonprime attribute an attribute of a relation schema R is called a prime attribute of R if it is a member of any candidate key of R an attribute is called nonprime if it is not a prime attribute, i.e. not a member of any candidate key of R Full functional dependency Y is said to be fully dependent on X if X Y and Z Y for any X Z Y is fully dependent on X if and only if Y is functionally dependent on X, and - not functionally dependent on any proper subset of X Partial functional dependency Y is said to be partially dependent on X if some attribute can be removed from X and the dependency still holds Transitive functional dependency
4
Second Normal Form (2NF)
A relation schema R is in 2NF if it is in 1NF and every nonprime attribute A in R is fully functionally dependent on every key of R R(SSN, pNumber, hours, eName, pName, pLocation) SSN pNumber hours SSN eName pNumber pName pLocation decomposed into R1(SSN, pNumber, hours) R2(SSN, eName) R3(pNumber, pName, pLocation)
5
Example for 1NF and 2NF FIRST(S#, P#, Status, City, Qty) S# P# Status City Qty S# City Status City Status Anomalies insertion: cannot record City for a supplier until he supplies something modification: City for a supplier appears many times deletion: deletion of last tuple for S# lose its City FIRST is not in 2NF, so decompose into SECOND(S#, Status, City) SP(S#, P#, Qty) S# City Status City Status S# P# Qty
6
Third Normal Form (3NF) A relation schema is in 3NF if it is in 2NF and no nonprime attribute of R is transitively dependent on any key Alternatively, a relation schema R is in 3NF if whenever a nontrivial functional dependency X -->A holds in R, then either (a) X is a super key of R or (b) A is a prime attribute of R EMP_DEPT(SSN, Ename, Bdate, Addr, D#, Dname, Dmgrssn) FDs: SSN Ename Bdate Addr D# D# Dname Dmgrssn Since Dname and Dmgrssn are transitively dependent on D# (not in 3NF) ED1(SSN, Ename, Bdate, Addr, D#) ED2(D#, Dname, Dmgrssn)
7
Example for 2NF and 3NF SECOND(S#, Status, City) SP(S#, P#, Qty) S# City Status City Status Anomalies insertion: cannot record new Status for a city without S# modification : Status for a City appears in many tuples deletion : delete only the second tuple for a particular City SECOND is not in 3NF, so decompose into SC(S#,City) CS(City, Status)
8
Boyce/Codd Normal Form (BCNF)
A relation schema R is in BCNF if whenever a nontrivial functional dependency X A holds in R, then X is a super key of R Difference with 3NF Drop the second condition in 3NF that allows A to be prime if X is not a superkey
9
3NF and BCNF example MovieStudio(title, year, length, filmType, studioName, studioAddr) title year length filmType studioName studioName studioAddr Key: {title, year} Hence, MovieStudio is not 3NF Decompose into MovieStudio1(title, year, length, filmType, studioName) MovieStudio2(studioName, studioAddr) Then we get a schema in BCNF.
10
All binary relations are in BCNF
Let A and B are all attributes Consider all possible cases, here there are totally 4 cases no nontrivial FD at all: {A, B} is a key, so in BCNF A B holds, B A does not hold {A} is a key, so in BCNF B A holds, A B does not hold: similarly A B holds, B A holds {A} and {B} are keys, so in BCNF
11
Multivalued dependency example
EMP(eName, pName, depName) Smith {X,Y} {John, Anna} Must repeat every combination due to 1NF Two independent one-many relationships are mixed in the same relation eName -->> pName eName -->> depName
12
Multivalued dependency definition
Let X, Y be sets of attributes in R Let Z be compliment of X Y Multivalued dependency (MVD) X -->> Y [X multidetermines Y] holds in R if and only if each X-value in R is associated with a set of Y-values in a way that does not depend on Z-values MVD and FD-MVD rules Complementation If X -->> Y, then X -->> T – X – Y where Ts are all attributes of R not among the A’s and B’s Augmentation If X -->> Y and V W, XW -->> YV Transitivity If X -->> Y and Y -->>Z, then X -->> Z – Y If X Y, then X -->> Y (i.e. an FD is a special case of an MVD)
13
Fourth normal form (4NF)
An MVD A1A2 … An -->> B1B2 … Bm for a relation R is trivial if: A’s B’s or A’s B’s are all attributes of R A relation R is in 4NF if whenever A1A2 … An -->> B1B2 … Bm is a nontrivial MVD, {A1, A2, …, An} is a superkey
14
4NF example Star(name, street, city, title, year) name -->> street city Star relation is not in 4NF, hence decompose into Star1(name, street, city) Star2(name, title, year) Note that both new relations are in 4NF
15
Relationship among normal forms
All relation schema 1NF 2NF 3NF BCNF 4NF 5NF In practice, it is best to have relation schemas in BCNF or in 3NF
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.