Functional Dependency

A functional dependency $$X \rightarrow Y$$ says that given any two tuples in r, if their $$X$$ values are the same, their $$Y$$ values must also be the same. Functional dependencies hold over all possible instances of the relation, that is, it is not possible to gain any insight on the functional dependencies of a table by looking at any particular instance of it.

Relationship With Keys
If $$K \rightarrow$$ All Attributes of $$R$$, then we say that $$K$$ is a superkey for $$R$$

Anomalies Arising From Functional Dependencies
Whenever a relation has functional dependencies that are not superkeys, there are some anomalies that may occur.

Update Anomaly
An update anomaly occurs when editing a tuple in a relation breaks the functional dependency that was previously existing

Insertion Anomaly
An insertion anomaly occurs when inserting a tuple into a relation violates the functional dependencies of that table

Deletion Anomaly
A deletion anomaly occurs when deleting tuples from a relation also deletes information relevant to a functional dependency

Functional Dependency Closure
The closure of a set of functional dependencies $$F$$ is denoted as $$F^+$$. The closure of $$F$$ contains all functional dependencies that can be implied through the rules of inference (including trivial dependencies).

Attribute Closure
Finding attribute closure is useful when we want to determine whether a certain functional dependency $$X \rightarrow Y$$ is in $$F^+$$.

The attribute closure of $$X$$ (denoted $$X^+$$) is computed by doing the following
 * 1) The attribute set $$X^+$$ starts as the same as the attribute(s) $$X$$
 * 2) Repeat this step until the attribute closure does not change. Go through the functional dependencies in $$F$$. If there is a functional dependency $$U \rightarrow V$$ and $$U$$ is in $$X^+$$, then add $$V$$ to $$U^+$$ as well

Examples
$$R = \{ A,B,C,D,E \}$$

$$F = \{ B \rightarrow CD, D \rightarrow E, B \rightarrow A, E \rightarrow C, AD \rightarrow B \}$$

Question 1
Is $$B \rightarrow E$$ in $$F^+$$

$$B^+ = \{ B \}$$

$$B^+ = \{ AB \}$$ using $$B \rightarrow A$$

$$B^+ = \{ ABCD \}$$ using $$B \rightarrow CD$$

$$B^+ = \{ ABCDE \}$$ using $$D \rightarrow E$$

Since $$E$$ is in $$B^+$$, we can say that $$B \rightarrow E$$ is in $$F^+$$. We can also say that $$B \rightarrow E$$ is a key because $$B^+$$ contains all the attributes in $$R$$