❖ Notation/Terminology |
Most texts adopt the following terminology:
upper-case letters from start of alphabet (e.g. A, B, C, ...) | ||
concatenation of attribute names (e.g. X=ABCD, Y=EFG ) | ||
upper-case letters, denoting set of all attributes (e.g. R) | ||
lower-case letter corresponding to schema (e.g. r(R)) | ||
lower-case letters (e.g. t, t', t1, u, v ) | ||
tuple[attrSet] (e.g. t[ABCD], t[X]) |
❖ Functional Dependency |
A relation instance r(R) satisfies a dependency X → Y if
We say that "Y is functionally dependent on X ".
Attribute sets X and Y may overlap; it is trivially true that X → X.
Notes:
❖ Functional Dependency (cont) |
Consider the following (redundancy-laden) relation:
Title | Year | Len | Studio | Star --------------+------+-----+-----------+--------------- King Kong | 1933 | 100 | RKO | Fay Wray King Kong | 1976 | 134 | Paramount | Jessica Lange King Kong | 1976 | 134 | Paramount | Jeff Bridges Mighty Ducks | 1991 | 104 | Disney | Emilio Estevez Wayne's World | 1995 | 95 | Paramount | Dana Carvey Wayne's World | 1995 | 95 | Paramount | Mike Meyers
Some functional dependencies in this relation
Title Year
Len
Title Year
Studio
Title Year
Star
❖ Functional Dependency (cont) |
Consider an instance r(R) of the relation schema R(ABCDE):
A | B | C | D | E ----+----+----+----+---- a1 | b1 | c1 | d1 | e1 a2 | b1 | c2 | d2 | e1 a3 | b2 | c1 | d1 | e1 a4 | b2 | c2 | d2 | e1 a5 | b3 | c3 | d1 | e1
Since A values are unique, the definition of fd gives:
❖ Functional Dependency (cont) |
Other observations:
In practice, choose a minimal set of fds (basis)
❖ Exercise: Functional Dependencies (i) |
Real estate agents conduct visits to rental properties
❖ Exercise: Functional Dependencies (i) (cont) |
The spreadsheet ...
P# | When | Address | Notes | S# | Name | CarReg ---+-------------+------------+---------------+-----+-------+------- P4 | 03/06 15:15 | 55 High St | Bathroom leak | S44 | Rob | ABK754 P1 | 04/06 11:10 | 47 High St | All ok | S44 | Rob | ABK754 P4 | 03/07 12:30 | 55 High St | All ok | S43 | Dave | ATS123 P1 | 05/07 15:00 | 47 High St | Broken window | S44 | Rob | ABK754 P1 | 05/07 15:00 | 47 High St | Leaking tap | S44 | Rob | ABK754 P2 | 13/07 12:00 | 12 High St | All ok | S42 | Peter | ATS123 P1 | 10/08 09:00 | 47 High St | Window fixed | S42 | Peter | ATS123 P3 | 11/08 14:00 | 99 High St | All ok | S41 | John | AAA001 P4 | 13/08 10:00 | 55 High St | All ok | S44 | Rob | ABK754 P3 | 05/09 11:15 | 99 High St | Bathroom leak | S42 | Peter | ATS123
Functional dependencies: P → A, A → P, S → m, S → C
❖ Functional Dependency (again) |
Above examples consider dependency within a relation instance r(R).
More important for design is dependency across all possible instances of the relation (i.e. a schema-based dependency).
This is a simple generalisation of the previous definition:
E.g. real estate example
❖ Functional Dependency (again) (cont) |
Can we generalise some ideas about functional dependency?
E.g. are there dependencies that hold for any relation?
❖ Inference Rules |
Armstrong's rules are general rules of inference on fds.
F1. Reflexivity e.g. X → X
F2. Augmentation e.g. X → Y ⇒ XZ → YZ
F3. Transitivity e.g. X → Y, Y → Z ⇒ X → Z
❖ Inference Rules (cont) |
Armstrong's rules are complete, but other useful rules exist:
F4. Additivity e.g. X → Y, X → Z ⇒ X → YZ
F5. Projectivity e.g. X → YZ ⇒ X → Y, X → Z
F6. Pseudotransitivity e.g. X → Y, YZ → W ⇒ XZ → W
❖ Inference Rules (cont) |
Example: determining validity of AB → GH, given:
F = { AB → E, AG → J, BE → I, E → G, GI → H }
AB → E | (given) | |||
E → G | (given) | |||
AB → G | (using F3 on 1,2) | |||
AB → AB | (using F1) | |||
AB → B | (using F5 on 4) | |||
AB → BE | (using F4 on 1,5) | |||
BE → I | (given) | |||
AB → I | (using F3 on 6,7) | |||
AB → GI | (using F4 on 3,8) | |||
GI → H | (given) | |||
AB → H | (using F3 on 9,10) | |||
AB → GH | (using F4 on 3,11) |
Produced: 5 Nov 2020