| Lesson 9 | Functional Dependencies in Database Normalization |
| Objective | Identify functional dependencies to support effective database normalization. |
A functional dependency is a relationship between two attributes in a database
where the value of one attribute - the determinant - uniquely determines the
value of another attribute - the dependent. The notation X → Y is read as "X determines Y" or "Y is functionally dependent on X."
For example, in a table storing customer information, a customer ID uniquely determines the customer's first name, last name, address, and phone number:
CustID -> CustFirst, CustLast, Address, Phone
For each unique CustID value, there is exactly one value for each of the dependent
attributes. Functional dependencies are the analytical foundation of database normalization: they
identify where redundancy exists and guide the decomposition of tables into well-structured
relations.
A functional dependency can also involve a multi-field determinant, where two or more attributes together determine another attribute. In an automobile insurance database, a policy number and car ID together determine the deductible and coverage plan:
PolicyNo, CarID -> Deductible, CoveragePlan
Understanding and correctly identifying functional dependencies is a prerequisite for achieving Second Normal Form, which requires that all non-key attributes depend fully on the entire primary key.
Identifying functional dependencies during normalization produces three concrete outcomes:
Identifying functional dependencies is not always straightforward. It requires a combination of analytical techniques and domain knowledge, most of which is gathered through requirements analysis - the process of understanding what data a system needs to store, what constraints apply to that data, and how the data elements relate to one another.
No single method reliably surfaces all functional dependencies in a complex schema. The following twelve techniques, used in combination, build a comprehensive picture of the dependencies present in a database:
EmployeeID → EmployeeName. Study business processes, collaborate with
domain experts and stakeholders, and document all explicit constraints - unique identifiers,
mandatory fields, and business-defined relationships.
StudentID always maps to
exactly one StudentName across all rows, that pattern supports a functional
dependency. Be cautious: sample data can suggest dependencies that the business rules do not
actually guarantee. Always verify against the business rules.
CourseNr always determine
CourseName? Does DeptID always determine DeptName?
Understanding what each attribute represents - and what uniqueness constraints apply to it -
is the most reliable way to identify functional dependencies.
Combining these techniques produces a robust and reliable picture of the functional dependencies in a database schema, tailored to the specific business context.
When working with a specific table, a practical two-question test can quickly identify whether a field is functionally dependent on the entire primary key - the core requirement for Second Normal Form:
If the answer to both questions is no, the field is likely not functionally dependent on the primary key, and the table probably violates 2NF. The field belongs in a different table where it is properly dependent on that table's primary key.
Consider a table with the composite primary key (PolicyNo, CarID). If
CoveragePlan is an attribute of the insurance policy rather than of the specific car
on that policy, it depends only on PolicyNo and not on the full composite key. This
partial dependency violates 2NF. CoveragePlan should be moved to a Policy table
where PolicyNo is the primary key.
The following two-step process provides a systematic method for deriving functional dependencies from an entity-relationship model. The Student-Course-Professor domain illustrates the approach.
Define the entities, their candidate keys, and their non-key attributes:
Student: Keys = {StudName}, {StudNr} Attributes = {StudAddr}
Course: Keys = {CourseNr}, {CourseName}
Course Edition: Keys = {CourseNr, Semester, Year}
Professor: Keys = {ProfName}
Two rules govern functional dependencies derived from entity attributes:
StudName and StudNr uniquely identify a student,
each determines the other: StudName → StudNr and
StudNr → StudName.StudNr determines StudAddr; CourseNr determines
CourseName.Applying these rules to the four entities yields five functional dependencies:
StudName → StudNrStudNr → StudNameStudNr → StudAddrCourseNr → CourseNameCourseName → CourseNrTwo relationships exist in this domain:
Two rules govern functional dependencies derived from relationships:
Applying these rules yields two additional functional dependencies:
StudNr, CourseNr, Semester, Year → Grade (Rule 4 - Grade is determined
by the specific student and specific course edition)CourseNr, Semester, Year → ProfName (Rule 3 - one professor per course
edition)For more complex relationships involving three entities - such as a Supplies relationship between Supplier, Part, and Project - check whether one entity is determined by the combination of the others. If each Project and Part combination has at most one Supplier:
Part, Project -> Supplier
When designing a database for an unfamiliar domain, requirements analysis is the most reliable source of functional dependency information. Conduct interviews with domain experts, review existing documentation, examine legacy systems, and study the business rules that govern how data is created, used, and modified.
There is no single method that works for every context. A database for a university scheduling system will require different analytical techniques than one for an insurance claims system or a manufacturing inventory. The twelve techniques described above should be combined and weighted according to what information is available and what the specific domain requires.
Finally, remember that functional dependencies are not static. They reflect business rules as they exist at the time of design. When business rules change - a policy that previously allowed one instructor per course is revised to allow co-instructors, for example - the functional dependencies in the schema must be re-evaluated and the normalization analysis repeated for the affected tables.
To reinforce your understanding of functional dependency identification, complete the exercise
below:
Functional Dependencies
Exercise
The next lesson covers the procedure for putting a relation into Second Normal Form (2NF), building on the functional dependencies identified here.