Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Database [ITC218]:
Example:
S {S#, SNAME, STATUS, CITY}
P {P#, PNAME, COLOR, WEIGHT, CITY}
SP {S#, P#, QTY}
In Suppliers/Parts Database shown above, could
delete CITY from S and insert into SP, but value
would be duplicated for every occurrence of a
particular value of S#, leading to redundancy
Database [ITC218]:
S#
SNAME
STATUS
CITY
S#
P#
QTY
S1
Smith
20
London
S1
P1
300
S2
Jones
10
Paris
S1
P2
200
S3
Blake
30
Paris
S1
P3
400
S4
Clark
20
London
S1
P4
200
S5
Adams
30
Athens
S1
P5
100
S1
P6
100
S2
P1
300
S2
P2
400
S3
P2
200
S4
P2
200
S4
P4
300
S4
P5
400
SP
P#
PNAME COLOUR
WEIGHT
CITY
P1
Nut
Red
12
London
P2
Bolt
Green
17
Paris
P3
Screw
Blue
17
Rome
P4
Screw
Red
14
London
P5
Cam
Blue
12
Paris
P6
Cog
Red
19
London
Database [ITC218]:
Database [ITC218]:
Database [ITC218]:
S#
STATUS
QTY
P#
CITY
S#
STATUS
QTY
P#
CITY
Database [ITC218]:
Database [ITC218]:
Decomposition
SECOND {S#, STATUS. CITY}
SP {S#, P#, QTY}
S#
STATUS
S#
QTY
P#
Database [ITC218]:
CITY
10
Database:
Second
S#
STATUS
CITY
S#
P#
QTY
S1
20
London
S1
P1
300
S2
10
Paris
S1
P2
200
S3
30
Paris
S1
P3
400
S4
20
London
S1
P4
200
S5
30
Athens
S1
P5
100
S1
P6
100
S2
P1
300
S2
P2
400
S3
P2
200
S4
P2
200
S4
P4
300
S4
P5
400
SP
11
Definition of 2NF
A relation is in 2NF iff (if and only if) it is in 1NF
and every nonkey attribute is irreducibly
dependent on the primary key
A nonkey attribute is a key that does not
participate in the primary key
This assumes there is only one candidate key,
which we can then assume is the primary key
Database [ITC218]:
12
S#
S#
13
STATUS
QTY
P#
CITY
14
15
16
STATUS
Database [ITC218]:
17
Definition of 3NF:
A relation is in 3NF iff it is in 2NF and every
nonkey attribute is nontransitively dependent
on the primary key
This implies that there are no mutual
dependencies between the nonkey attributes
A relation that is in 2NF can always be
transformed by means of projections into a
collection of 3NF relations
Database [ITC218]:
18
19
20
21
Database [ITC218]:
22
23
24
Database [ITC218]:
25
Database [ITC218]:
26
Database [ITC218]:
27
28
29
1.
2.
3.
30