]
>
Requirements on Decompositions
Requirements on Decompositions
12.1 Preserving Dependencies
- Decomposition of schemes based on functional dependencies is motivated by separating data into topics.
|
| St-Name | Status | Course-Name | Course-# | Salary |
| Ben | senior | db | 670 | 500 |
| Ben | senior | ds | 680 | 500 |
| Dan | freshment | db | 670 | 400 |
| Dan | freshment | ds | 680 | 600 |
|
|
| St-Name
Status |
|
| St-Name | Course-Name | Course-# | Salary |
| Ben | db | 670 | 500 |
| Ben | ds | 680 | 500 |
| Dan | db | 670 | 400 |
| Dan | ds | 680 | 600 |
|
|
|
| St-Name | Status |
| Ben | senior |
| Dan | freshment |
|
|
| Course-#
Course-Name |
|
| St-Name | Course-# | Salary |
| Ben | 670 | 500 |
| Ben | 680 | 500 |
| Dan | 670 | 400 |
| Dan | 680 | 600 |
|
|
|
| Course-Name | Course-# |
| db | 670 |
| ds | 680 |
|
|
- 1NF, 2NF, 3NF, BCNF relate to integrity constraints verifiable within a schema
- Consider FD over, but not across, schema
| Eyes |
| SSN | ColorName | Red | Green | Blue |
| 123-45-6789 | brown | 165 | 42 | 42 |
| 234-56-7890 | green | 0 | 255 | 0 |
|
| SSN
ColorName ColorName
Red Green Blue |
- Bad: Decomposition on SSN
ColorName
-
| ByName |
| SSN | ColorName |
| 123-45-6789 | brown |
| 234-56-7890 | green |
|
| SSN
ColorName
|
| ByRGB |
| SSN | Red | Green | Blue |
| 123-45-6789 | 165 | 42 | 42 |
| 234-56-7890 | 0 | 255 | 0 |
|
| SSN
Red Green Blue |
- Natural join: Gives back the original data
- Lost ‘topic’: ColorName
Red Green Blue
- Good: Decomposition on ColorName
Red Green Blue
-
| ByName |
| ColorName | Red | Green | Blue |
| brown | 165 | 42 | 42 |
| green | 0 | 255 | 0 |
|
| ColorName
Red Green Blue |
| ByRGB |
| SSN | ColorName |
| 123-45-6789 | brown |
| 234-56-7890 | green |
|
| SSN
ColorName
|
- Decompositions should ensure representation of each functional dependency in the decomposed relations
Given:
A BCDE
CD
E
CE
B
Normalized:
A
BCD
CD
E
CE B fails: B is not in
CE
Note: The dependencies are preserved for a decomposition to R1=(A,C,D) and R2=(B,C,D,E)
- Objective: Introduce a dependency-preserving 3NF decomposition algorithm
- The subset of the
closure which uses
only attributes of
is the projection of F on X
- A decomposition of
into and
is dependency
preserving if
Minimal Cover
is a minimal set
of FDs if each
is
- Canonical:
- Left-reduced:
can’t be replaced by a subset
- Non-redundant:
can’t be removed
Note
- may be
replaced by , if
is still in the
closure of
- may be
replaced by , if
is still in the
closure of
A Dependency-Preserving 3NF Decomposition Algorithm
- Find minimal cover
- Put FDs agreeing on the left-hand-side in the same schema
- Have extra schema for unaccounted attributes
A synthesis algorithm for defining schemas directly from the FDs.
12.2 Lossless (Nonadditive) Joins
- Decompositions are projections of relational schemas
- Old tables should be derivable from the newer ones through the natural join operation
|
| A | B | C |
| a1 | b1 | c1 |
| a2 | b2 | c2 |
| a3 | b1 | c3 |
| a1 | b1 | c3 |
| a3 | b1 | c1 |
|
The decomposition is improper as the natural join introduces extra improper records.
- ,
is a lossless join
decomposition of iff the
attributes common to
and
contain a key for at least one of the involved relations
Testing
Given:
Decomposition
of
Attributes
FDs
- Create
matrix
- Initialize
:= , if
is in
:=
,
otherwise
- If on
, for
,
adjust the rows to agree also
on corresponding attributes of
- Propogate ’s,
when possible
- Propogate any ’s,
if no is
available
- A lossless join decomposition iff there a exist a row of
’s
(Figure 15.1(c), p 507)
A Dependency-Preserving Lossless-Join 3NF Decomposition Algorithm
- Find minimal cover
- Put FDs agreeing on the left-hand-side in the same schema
- Have extra schema for a key, if none of the above schemas contain a key
12.3 Life is Not Easy
- Schemas can always employ lossless-join dependency-preserving decompositions to achieve 3NF
- Determining whether a relationship schema satisfies 3NF is NP-complete. Hence, good design can’t rely too
heavily on automated normalization.
- Not all violations to BCNF can be resolved through dependency-preserving decompositions
PROJECT,
DEPT
MANAGER
MANAGER
DEPT
- Doesn’t satisfy BCNF
- Decompositions can’t preserve dependencies
- 3NF is satisfied
Reference: Ch. 11.1-11.2 in textbook.