Functional Dependency

COMP3311 20T3 ♢ Functional Dependency ♢ [0/12]
❖ Notation/Terminology


Most texts adopt the following terminology:

Attributes upper-case letters from start of alphabet (e.g. A, B, C, ...)
Sets of attributes concatenation of attribute names (e.g. X=ABCD, Y=EFG )
Relation schemas upper-case letters, denoting set of all attributes (e.g. R)
Relation instances lower-case letter corresponding to schema (e.g. r(R))
Tuples lower-case letters   (e.g. t, t', t1, u, v )
Attributes in tuples tuple[attrSet] (e.g. t[ABCD], t[X])

COMP3311 20T3 ♢ Functional Dependency ♢ [1/12]
❖ Functional Dependency

A relation instance r(R) satisfies a dependency X → Y  if

In other words, if two tuples in R agree in their values for the set of attributes X, then they must also agree in their values for the set of attributes Y.

We say that "Y  is functionally dependent on X ".

Attribute sets X and Y may overlap;   it is trivially true that X → X.

Notes:

COMP3311 20T3 ♢ Functional Dependency ♢ [2/12]
❖ 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

Not a functional dependency
COMP3311 20T3 ♢ Functional Dependency ♢ [3/12]
❖ 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:

Since all E  values are the same, it follows that:
COMP3311 20T3 ♢ Functional Dependency ♢ [4/12]
❖ Functional Dependency (cont)

Other observations:

We could derive many other dependencies, e.g.   AE → BC, ...

In practice, choose a minimal set of fds (basis)

COMP3311 20T3 ♢ Functional Dependency ♢ [5/12]
❖ Exercise: Functional Dependencies (i)

Real estate agents conduct visits to rental properties

The company stores all of the associated data in a spreadsheet.
COMP3311 20T3 ♢ Functional Dependency ♢ [6/12]
❖ 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

COMP3311 20T3 ♢ Functional Dependency ♢ [7/12]
❖ 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:

Such dependencies tend to capture semantics of problem domain.

E.g. real estate example

COMP3311 20T3 ♢ Functional Dependency ♢ [8/12]
❖ Functional Dependency (again) (cont)


Can we generalise some ideas about functional dependency?


E.g. are there dependencies that hold for any relation?


E.g. do some dependencies suggest the existence of others?
COMP3311 20T3 ♢ Functional Dependency ♢ [9/12]
❖ 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
COMP3311 20T3 ♢ Functional Dependency ♢ [10/12]
❖ 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
COMP3311 20T3 ♢ Functional Dependency ♢ [11/12]
❖ Inference Rules (cont)

Example: determining validity of AB → GH, given:

R = ABCDEFGHIJ

F = { AB → E,   AG → J,   BE → I,   E → G,   GI → H }

Derivation:
1.   AB → E (given)
2.   E → G (given)
3.   AB → G (using F3 on 1,2)
4.   AB → AB (using F1)
5.   AB → B (using F5 on 4)
6.   AB → BE (using F4 on 1,5)
7.   BE → I (given)
8.   AB → I (using F3 on 6,7)
9.   AB → GI (using F4 on 3,8)
10. GI → H (given)
11. AB → H (using F3 on 9,10)
12. AB → GH (using F4 on 3,11)
COMP3311 20T3 ♢ Functional Dependency ♢ [12/12]


Produced: 5 Nov 2020