liveBook · Manning

Functional dependency

As explained in Grokking Relational Database Design

A functional dependency is a constraint in which a value or set of values in one or more columns uniquely determines the value of another column.

A functional dependency means that one column, or a combination of columns, uniquely determines another column. It is directional: employee_id → employee_name does not imply that employee_name → employee_id. section 6.5

A purchase example

In a purchase table, purchase_id determines receipt details such as total_price and purchase_time. However, product_quantity and product_price depend on the combination of purchase_id and code; neither column determines them alone. Moving those attributes to a purchase_product table with that combination as its key removes the dependency problem. section 6.6

Use functional dependencies to check whether each table is organized around the right key:

product_id → total_price, purchase_time, payment_id, email
purchase_id, code → product_quantity, product_price

Browse the dependency listing for the purchase table and its purchase-product relationship. section 6.6

How Grokking Relational Database Design covers it

How deep it goes
Explains direction, single-column and composite dependencies, and transitive chains, then stops short of edge cases.
Examples
Uses employee, purchase, product, supplier, department, and purchase_product tables to demonstrate dependencies and decomposition.
What it assumes
Assumes basic tables and keys while teaching functional dependency through a familiar programming-function analogy.
What you can do after
Apply it via normalization by locating wrongly dependent columns and moving them into appropriately keyed tables.
How it connects
Connects functional dependency to normalization, primary keys, composite keys, BCNF, 3NF, and foreign keys.

Also explained in

Compare how 2 books explain functional dependency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.