Download presentation
Presentation is loading. Please wait.
1
Normal forms - 1NF, 2NF and 3NF
(under the assumption of relations with just one candidate key)
2
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
3
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
4
1NF a relation is in 1NF if and only if all the domains of its attributes contain only scalar values
5
Relation in 1NF : Students-Info
6
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
7
FD diagram for 1NF not all the determinants are the primary key
8
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
9
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
10
Non-loss decomposition
11
Activity consider different relations and experiment with different decompositions - identify which ones are lossy and which ones are non-loss
12
Heath’s theorem Suppose A, B and C are sets of attributes of a relation R, such that AB and heading(R) = A B C then R = {A, B} JOIN {A, C}
13
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
14
2NF - update anomalies consider the relation “Module” insert delete
insert that a “3sem” module is worth “1.5cu” delete exercise modify (update)
15
FD for 2NF transitive dependency
16
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
17
Modules - decomposed (non-loss)
18
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
© 2024 SlidePlayer.com. Inc.
All rights reserved.