# Normal forms - 1NF, 2NF and 3NF

## Presentation on theme: "Normal forms - 1NF, 2NF and 3NF"— Presentation transcript:

Normal forms - 1NF, 2NF and 3NF
(under the assumption of relations with just one candidate key)

Aim to familiarise with the concept of a normal form
simplifying assumption (SA) every relation has one candidate key only, which is, therefore, the primary key

Generalities normal forms
expressing FD constraints through choosing the structure of relations (structure  the component attributes) 3NF  2NF  1NF transforming a relation into a higher normal form (vertical) decomposition - projection non-loss decomposition

1NF a relation is in 1NF if and only if all the domains of its attributes contain only scalar values

Relation in 1NF : Students-Info

1NF - update anomalies insert: exercise delete: exercise
modify (update) suppose “Databases” changes to “3sem” and “1.5cu” the modification must be performed in more than one tuple; it implies a search; this structure (1NF) does not enforce consistent data; i.e. inconsistencies can be generated (e.g. by mistake) (implementation aspect) an update (involving a search) can be expressed by means of a single SQL statement, but the search still has to be performed an incorrect statement can generate inconsistencies

FD diagram for 1NF not all the determinants are the primary key

2NF A relation (with just one CK) is in 2NF if and only if it is in 1NF and every non-key attribute is irreducibly dependent on the primary key “Students-Info” is not 2NF; it can be decomposed into a set of relations in 2NF the equivalence must be preserved

Non-loss decomposition
a decomposition of R into its projections R1, …, Rn is non-loss if and only if the natural join of R1, …, Rn results in the initial R

Non-loss decomposition

Activity consider different relations and experiment with different decompositions - identify which ones are lossy and which ones are non-loss

Heath’s theorem Suppose A, B and C are sets of attributes of a relation R, such that AB and heading(R) = A  B  C then R = {A, B} JOIN {A, C}

Pragmatic principles when you apply Heath’s theorem look for a maximum set of attributes B this will minimise the number of tables in the database try to maintain a one to one correspondence with real life entities

2NF - update anomalies consider the relation “Module” insert delete
insert that a “3sem” module is worth “1.5cu” delete exercise modify (update)

FD for 2NF transitive dependency

3NF A relation (with just one CK) is in 3NF if and only if it is in 2NF and every non-key attribute is non-transitively dependent on primary key alternatively … if there are no FDs between non-key attributes

Modules - decomposed (non-loss)

Concluding remarks all definitions given were for relations with just 1CK any relation can be decomposed into a set of 3NF relations 3NF is always achievable are all non-loss decompositions equivalent? what happens in the case of relations with more than 1CK?

Similar presentations