Database Systems · Functional Dependencies
Using Functional Dependencies to Eliminate Redundancy
Overview
A functional dependency A → B means that a value of A uniquely determines the value of B. Recognising such dependencies lets us remove redundant repetition from a relation by splitting it into smaller tables, a process called decomposition.
Key concepts
- Functional dependency (FD): B is functionally dependent on A, also stated as "A determines B" or "A functionally determines B", written A → B. Given a value of A, the value of B is uniquely determined.
- Direct consequence: if A → B holds, then whenever A repeats, B must also repeat the same value.
- Redundancy: if A repeats many times, storing B next to every occurrence repeats the same B value again and again, which is wasted space.
- Decomposition: splitting a table using functional dependencies. FDs tell us which areas of a table can be minimised further.
- Goal of decomposition: for every functional dependency, the left-hand side (the determining attribute) should act as the primary key of the new table.
How it works
- In a relation, identify that A → B holds: given the value of A, the value of B can always be found.
- Every time A repeats, B is forced to repeat the same value. If A repeats 100 times, B repeats the same value b1 100 times, which is completely a waste of space.
- Storing B again and again next to A creates all these redundant values.
- Delete column B from the big table. For example, a big table with A, B, C, D, E, F, G, H becomes A, C, D, E, F, G, H, saving a lot of space.
- Save B separately in a new table (A, B), writing each pair such as A = 1, B = 2 only once.
- Even if the pair was repeated 100 times in the original table, it is written only one time in the new table.
- On a big relation with many attributes, find the areas with lots of repetitions (a pattern like A A A A with 1 1 1 1), identify all such spots, and make each of them a separate table using just that one determining attribute.
Formulas
A -> B B is functionally dependent on A; A determines B
Worked examples
Before decomposition — one big relation R(A, B, C, D, E, F, G, H) with A → B:
| A | B | other attributes C, D, E, F, G, H |
|---|---|---|
| 1 | 2 | their own values |
| 1 | 2 | their own values |
| 1 | 2 | their own values |
| ... (A repeats, say 100 times) | 2 repeated 100 times | ... |
The value of B is 2 (the value itself does not matter; it could even be 1). What matters is that the same B value is stored again and again because A repeats, which is pure wasted space.
After decomposition — two tables:
Table 1: B is simply deleted from the big table.
| A | C | D | E | F | G | H |
|---|---|---|---|---|---|---|
| 1 | ... | ... | ... | ... | ... | ... |
Table 2: new table containing only A and B.
| A | B |
|---|---|
| 1 | 2 |
Result: instead of writing B's value 100 times, it is written once, and the same information is preserved because A is present in both tables, so the pairings can be recovered.
Comparison
| Single big table (A, B, C, D, E, F, G, H) | After decomposition into (A, C, D, E, F, G, H) and (A, B) | |
|---|---|---|
| Storage of B | Repeated as many times as A repeats (e.g. 100 copies) | Stored only once (one row in the A, B table) |
| Redundancy | High | Removed |
| Space | Wasted | Saved |
| What holds it together | — | A → B, with A acting as the key of the new table |
Revision summary
- A → B means given A, the value of B is uniquely determined.
- Whenever A repeats, B repeats the same value; that repetition is redundant data occupying space.
- Fix: delete B from the big table and keep a separate table (A, B) holding each pair only once, however many times it occurred originally.
- This is useful precisely when there are lots of repetitions of A in the relation.
- On a large relation, scan for spots with heavy repetition (patterns like A A A A with 1 1 1 1) and convert each into a separate table.
- Splitting tables using FDs is called decomposition.
- For every FD, the left-hand-side (determining) attribute becomes the primary key of the new table.
Previous-year exam insights
- A decomposition is lossless if the common attributes of the two resulting relations form a superkey of at least one of them; otherwise the original relation cannot be recovered by a natural join.
- A decomposition is dependency preserving if the union of the FDs projected onto the smaller relations is equivalent to the original set of FDs; lossless-join and dependency preservation are independent properties and cannot always both be achieved (3NF guarantees both, BCNF guarantees only lossless join).
- A relation is in 2NF if it is in 1NF and every non-prime attribute is fully functionally dependent on every candidate key, i.e. no partial dependency of a non-prime attribute on part of a candidate key.
- A relation is in 3NF if for every non-trivial FD X → A, either X is a superkey or A is a prime attribute; it is in BCNF if for every non-trivial FD X → A, X is a superkey.
- Armstrong's axioms (reflexivity, augmentation, transitivity) are sound and complete for deriving all FDs implied by a given set; the closure of an attribute set X is the set of all attributes functionally determined by X.
- Redundancy is not removed by decomposition alone: a table is free of redundancy from an FD only when the determinant is a candidate key, so decomposing on a non-key determinant can still leave repetition or cause loss of information.