CSE Roadmap

Common tier · about 3 hours · 5 parts

Part 2 of 5 · 1 min read

What a functional dependency is

X determines Y: knowing X's value always tells you Y's value.

Think of a lookup table mapping a book's ISBN to its exact title. Knowing the ISBN always tells you the title. Nothing about a given ISBN ever has two different titles.

In plain words: a functional dependency X → Y means that knowing the value of X always determines the value of Y. For any two rows sharing the same X value, Y must also be the same in both.

A worked example. In books, book_id → title holds, since every row with the same book_id has the same title. title → book_id does not necessarily hold, if two different books could share the same title.

The key lines. Checked directly against real data:

SELECT book_id, COUNT(DISTINCT title) FROM books GROUP BY book_id HAVING COUNT(DISTINCT title) > 1;

An empty result confirms book_id → title holds for the current data.

Functional dependency

A functional dependency X → Y means every pair of rows sharing the same X value also shares the same Y value.

Example: book_id → title holds in books, since no two rows share a book_id with different titles.