Functional Dependency in a Database

Functional Dependencies Help Avoid Data Duplication

Format
mla apa chicago
Your Citation
Chapple, Mike. "Functional Dependency in a Database." ThoughtCo, Nov. 12, 2016, thoughtco.com/functional-dependency-definition-1019257. Chapple, Mike. (2016, November 12). Functional Dependency in a Database. Retrieved from https://www.thoughtco.com/functional-dependency-definition-1019257 Chapple, Mike. "Functional Dependency in a Database." ThoughtCo. https://www.thoughtco.com/functional-dependency-definition-1019257 (accessed October 24, 2017).
Woman holding report in office, close-up
Ken Reid/Taxi/Getty Images

A functional dependency in a database enforces a set of constraints between attributes. This occurs when one attribute in a relation uniquely determines another attribute. This can be written A -> B which means "B is functionally dependent upon A." This is also called a  database dependency

In this relationship, A determines the value of B, while B depends on A.

Why Functional Dependency is Important in Database Design

Functional dependency helps ensure the validity of data.Consider a table Employees that lists characteristics including Social Security Number (SSN), name, date of birth, address and so on.

The attribute SSN will determine the value of name, date of birth, address and perhaps other values, because a social security number is unique, while a name, date of birth or address may not be. We can write it like this:

SSN -> name, date of birth, address

Therefore, name, date of birth and address are functionally dependent on SSN. However, the reverse statement (name -> SSN) is not true because more than one employee can have the same name but will never have the same SSN. Put another, more concrete way, if we know the value of the SSN attribute, we can find the value of name, date of birth and address. But if we instead know the value of only the name attribute, we cannot identify the SSN.

The left side of a functional dependency can include more than one attribute. Let's say we have a business with multiple locations. We might have a table Employee with attributes employee, title, department, location and manager.

The employee determines the location he's working, so there's a dependency:

employee -> location

But the location might have more than one manager, so employee and department together determine the manager:

employee, department -> manager

Functional Dependency and Normalization

Functional dependency contributes to what is called database normalization, which ensures data integrity and reduces data redundancies.

Without normalization, there is no assurance that the data in a database is accurate and dependable.  

Format
mla apa chicago
Your Citation
Chapple, Mike. "Functional Dependency in a Database." ThoughtCo, Nov. 12, 2016, thoughtco.com/functional-dependency-definition-1019257. Chapple, Mike. (2016, November 12). Functional Dependency in a Database. Retrieved from https://www.thoughtco.com/functional-dependency-definition-1019257 Chapple, Mike. "Functional Dependency in a Database." ThoughtCo. https://www.thoughtco.com/functional-dependency-definition-1019257 (accessed October 24, 2017).