Understanding Functional Dependencies

I'm currently learning about functional dependencies and am struggling to get my head around the concept behind them.

Say I have the table:

Customer

|-----------|--------------|------------|------------------|------------------|
|Cust-ID    | Cust-FName   |Cust-LName  |Cust-Email        |Cust-Pw           |
|-----------|--------------|------------|------------------|------------------|
|1          |John          |Smith       |jsmith@email.com  |srt6564sdgjhy55y  |
|2          |Adam          |Borneo      |adb@hotmail.com   |45657ythjdfgqAfd  |
-------------------------------------------------------------------------------

There are two candidate keys: cust-ID and cust-Email (only one email address may belong to one customer). Electing cust-ID as the P.K, would the only functional dependency be:

{Cust-ID} -> {Cust-FName, Cust-LName, Cust-Email, Cust-Pw} ?

Or, would I draw/represent both candidate keys:

{Cust-ID} -> {Cust-FName, Cust-LName, Cust-Email, Cust-Pw}

{Cust-Email} -> {Cust-ID, Cust-FName, Cust-LName, Cust-Pw} ?

Instincts tell me the former, but given this is a completely new topic I'd appreciate any help!

Answers


Functional dependency set is always a superset of [candidate] keys. In other words a key is a functional dependency with attribute list covering the whole relation. Therefore, both candidate keys that you listed are also functional dependencies.


Both

{Cust-ID} -> {Cust-FName, Cust-LName, Cust-Email, Cust-Pw}

{Cust-Email} -> {Cust-ID, Cust-FName, Cust-LName, Cust-Pw}

are functional dependencies in your case.

A functional dependency is a situation like this: whenever you have two rows which have the same value for column on the left hand-side of the arrow, then the values for columns on the right hand side of the arrow have to be equal. If you have two rows with the same Cust-ID then the name, email, and password columns have to be the same. If you have two rows with the same Cust-Email then (in your example) the name, email, and password columns have to be the same.

If your table in not in the third normal form, then it IS possible that you have functional dependency with a proper subset of the key on the left hand side. In fact, you define the candidate key and the normal forms (2NF, 3NF, BCNF) in terms of functional dependencies.

You can read more on functional dependencies on our company blog. It is the first part in a series of posts on data normalization.


Need Your Help

Retrieving JSON Data using extras as a parameter of a constructor

android json

Hi guys I am trying to retrieve some movie information in JSON format but I cannot seem to work out what the problem of my code is. The data retrieving and processing itself all works but the probl...

What is The Correct Way To Delete A has_one Association From a Link

ruby-on-rails ruby activerecord associations has-one

I have a NewsItem model which has_one :photo. I would like to allow a user to quickly delete this association from a link (without having to use an Edit NewsItem form).