CP363 : Functional Dependencies

There are two basic design methodologies for designing a database:

Bottom-Up Design Methodology
Starts with all possible individual attributes for a database and builds relationships from that. Rarely used and unpopular.
Top-Down Design Methodology
Starts with tables and relations that have already been defined conceptually, and further refines the database design. The concepts of functional dependency and normalization are used with this methodology as criteria for proper database design.

What is a "good" relational database design?

Independent data in separate tables, i.e.: Each table should consist of a primary key and a set of mutually independent attributes

Functional dependency and normalization are tools for good relational database design.


Functional Dependency

A set of attributes Y is functionally dependent on a set of attributes X ( X→Y ) when Y can be uniquely determined by X. This can be read as "X functionally determines Y", or as "Y is functionally determined by X". Note that the converse, Y→X, is not necessarily true.

This is not to say that because X is unique Y is also unique. For example, although {Student_ID,Course}→Grade, (i.e. a student in a given course may have only one grade, for example an 'A'), other students may also have an 'A' in the same course. It simply means that a particular student in a particular course has one and only one grade. As well, clearly Grade→{Student_ID,Course} is not true.

A functional dependency is a type of constraint on attributes that arises out of the meaning of those attributes. In other words, in any given tuple the value of one set of attributes depends on the value of another set of attributes. These depend on the semantics, or rules, underlying the relation in question. The previous example, {Student_ID,Course}→Grade, could turn out to be false if a student is allowed to take the same course in a different term. Then you could infer that the functional dependency should be {Student_ID,Course,Term}→Grade instead. It is not always easy to infer a functional dependency, although it takes only a single violation of an FD to falsify it, i.e. show that it is false.

Based upon the first example from the Anomalies web page:

Student_ID Course Dept Last_Name First_Name Instructor Grade
999568440 CP363 Computing Snord Cranston D. Brown F
999568440 CP400 Computing Snord Cranston T. Yang A-
999568440 CP102 Computing Snord Cranston D. Brown C
987859400 PC466 Physics Zzap Zachary B. Pavlova D
987859400 HP202 History Zzap Zachary S. Zeller D
987859400 CP102 Computing Zzap Zachary D. Brown B+
005689250 CP102 Computing Snord Lillibelle D. Brown A+

Based upon the data we can see, we can claim the following:


Some FD Rules:

A minimal set of dependencies is a set of dependencies that has:

There may not be a unique set of FDs that can be used to describe a set of relations in a database. However, a minimal cover set of FDs is a set of the smallest number FDs that meets the above requirements.

Why are functional dependencies useful? An FD represents an integrity constraint - i.e. semantics can be rendered into database constraints. Further they can aid in the normalization of a set of relations. Properly defining a minimal set of FDs can help remove anomalies from table and relationship designs. For example, does the sample table on this page represent a minimal set of functional dependencies for the data used?