Simulators
Functional dependency tool
Type the attributes of a relation and its functional dependencies, one per line, like A -> B. Choose a set X and watch its closure X⁺ grow one dependency at a time.
The simulator
How the Functional dependency tool works
A functional dependency X -> Y says that if two rows agree on X they must agree on Y. The closure X+ of a set of attributes is everything X determines: start with X, and keep adding the right-hand side of any dependency whose left-hand side is already inside, until nothing new is added.
A candidate key is a smallest set of attributes whose closure is every attribute. The tool finds all of them, then uses them to decide the highest normal form (1NF, 2NF, 3NF or BCNF) and names the dependency that breaks the next one. It also builds a minimal cover: an equivalent set of dependencies with single attributes on the right, no extra attributes on the left and no redundant dependency.
Worked example: closure, keys and normal form
Relation R(A, B, C, D, E) with the dependencies A → B, B → C, CD → E. Find the closure of {A, D}.
| Start with | Use dependency | Adds | Set becomes |
|---|---|---|---|
| AD | A → B | B | ABD |
| ABD | B → C | C | ABCD |
| ABCD | CD → E | E | ABCDE |
{A, D}+ = {A, B, C, D, E}: it reaches all 5 attributes, so AD is a superkey. Neither A alone (A+ = {A, B, C}) nor D alone is enough, so AD is a candidate key. The candidate keys are: AD.
The relation is in 1NF. The only candidate key is AD. Prime attributes: AD. Non-prime: BCE. Not in 2NF: a non-prime attribute depends on only part of a candidate key. A is only part of the key AD, yet A⁺ gives the non-prime BC. The minimal cover is A → B, B → C, CD → E.
Questions about the Functional dependency tool
- How do you find the closure of an attribute set?
- Start with the set and apply every dependency whose left side is already in it, adding its right side, until nothing changes. For {A, D} that takes 3 dependencies and gives {A, B, C, D, E}.
- How do you find the candidate keys of a relation?
- Find the smallest sets whose closure is all attributes. Here A+ is {A, B, C}, which is not everything, and {A, D}+ is everything, so the only candidate key is AD. Attributes that never appear on a right-hand side must be in every key.
- How do you tell which normal form a relation is in?
- Check the dependencies against the keys. In 2NF no non-prime attribute depends on only part of a candidate key. In 3NF every dependency has a superkey on the left or a prime attribute on the right. In BCNF every left-hand side is a superkey. This relation is in 1NF: A is only part of the key AD, yet A⁺ gives the non-prime BC.
- What is a minimal (canonical) cover?
- A smaller set of dependencies with the same closure: one attribute on each right side, no extra attribute on a left side, and no dependency that the others imply. For this relation it is A → B, B → C, CD → E.
Functional dependency tool: how to use it
The tool also finds the candidate keys, builds a minimal (canonical) cover in three steps, and tells you whether the relation is in 1NF, 2NF, 3NF or BCNF, with the dependency that breaks the next form.
Lessons that use it
- Normalization (DBMS)Why one big table goes wrong (update, insert and delete anomalies), functional dependencies, and the normal forms 1NF, 2NF, 3NF and BCNF that split it into good tables.
See also
- CPU scheduling simulator
- Page replacement simulator
- Memory allocation simulator
- Banker's algorithm simulator
- Disk scheduling simulator
- Race condition simulator
- Truth table maker
- Gradient descent simulator
- K-means clustering simulator
- Subnetting in binary
- Sliding window simulator
- TCP congestion control simulator
- Karnaugh map practice
- Flip-flop simulator
- Ripple-carry adder
- Cache simulator
- 5-stage pipeline simulator