Suppose, I have a Table with the columns:
- person_id (primary key)
- first_name
- last_name
- birthday
I also have a unique constraint on the combination {first_name, last_name} (I know that more people can have the same name, but I want to keep my example simple). I want to know whether this Table is in Third normal form.
My reasoning (before EDIT):
- All fields can only contain atomic values, so the Table is in First normal form.
- The candidate keys are 1) person_id, 2) [first_name, last_name]
- The only non-prime attribute is birthday.
- The attribute birthday is not functionally dependent on part of candidate key 1 (which is impossible anyway, since there is only 1 attribute in candidate key 1)
- The attribute birthday is not functionally dependent on part of candidate key 2
- Therefore, this Table is in Second normal form.
- The attribute birthday (is/is not) non-transitively dependent on candidate key 1
- The attribute birthday is non-transitively dependent on candidate key 1
The Question (before EDIT):
The question that I cannot answer is if birthday is non-transitively dependent on person_id. Functionally, there is no relationship at all between this id number and the birthday.
- Does this mean that there is a transitive dependency (birthday depends on [first_name, last_name], and each combination [first_name, last_name] maps to an id) and therefore not in 3NF?
- Does this mean that there is no dependency at all, and therefore not in 3NF?
- Am I misinterpreting the difficult language and is this Table in 3NF?
My reasoning (after EDIT):
- If you know the person_id, you know his first name, last name and his birthday, so there are the FDs {person_id} -> {first_name}, {person_id} -> {last_name} and {person_id} -> {birthday}.
- If you know a person's first and last name, you know his person_id and birthday, so there are the FDs {first_name, last_name} -> {person_id} and {first_name, last_name} -> {birthday}.
If you know a person's birthday, you don't know anything about his person_id or name, so there are no FDs from birthday to another (set of) attribute(s).
All fields can only contain atomic values, so the Table is in First normal form.
- The candidate keys are 1) {person_id}, 2) {first_name, last_name}
- The only non-prime attribute is {birthday}.
- The attribute {birthday} is not FD on part of CK 1 (which is impossible anyway, since there is only 1 attribute in CK 1)
- The attribute {birthday} is not FD on part of CK 2
Therefore, this Table is in Second normal form.
There is an FD {person_id} -> {birthday}, so the attribute {birthday} is non-transitively dependent on CK 1
- There is an FD {first_name, last_name} -> {birthday}, so the attribute {birthday} is non-transitively dependent on CK 2
- Therefore, this Table is in Third normal form.
There is a dependency {person_id} -> {first_name, last_name} -> {birthday}, but since there is also a direct dependency {person_id} -> {birthday}, this dependency is not transitively.
The Question (after EDIT):
I don't have a predefined set of FDs from a book, so I am not sure whether the FDs are correct. Can someone confirm this, or if they don't look right, show how I can find the FDs in this practical example?
Third reasoning (second EDIT):
FD's:
- If you only know a person's person_id, you know his first name, last name and his birthday (there cannot be multiple people with the same person_id)
- FD: {person_id} -> {first_name}
- FD: {person_id} -> {last_name}
- FD: {person_id} -> {birthday}
- Supersets including {person_id} no longer need to be considered
- If you only know a person's first_name, you don't know any other field of this person (there can be multiple people with the same first_name)
- Not FD: {first_name} -> {person_id}
- Not FD: {first_name} -> {last_name}
- Not FD: {first_name} -> {birthday}
- If you only know a person's last_name, you don't know any other field of this person (there can be multiple people with the same last_name)
- Not FD: {last_name} -> {person_id}
- Not FD: {last_name} -> {first_name}
- Not FD: {last_name} -> {birthday}
- If you only know a person's birthday, you don't know any other field of this person (there can be multiple people with the same birthday)
- Not FD: {birthday} -> {person_id}
- Not FD: {birthday} -> {first_name}
- Not FD: {birthday} -> {last_name}
- If you know a person's first_name and last_name, you know his person_id and his birthday (there cannot be multiple people with the same first_name and last_name)
- FD: {first_name, last_name} -> {person_id}
- FD: {first_name, last_name} -> {birthday}
- Supersets including {first_name, last_name} no longer need to be considered
- If you know a person's first_name and birthday, you don't know any other field of this person (there can be multiple people with the same first_name and birthday)
- Not FD: {first_name, birthday} -> {person_id}
- Not FD: {first_name, birthday} -> {last_name}
- If you know a person's last_name and birthday, you don't know any other field of this person (there can be multiple people with the same last_name and birthday)
- Not FD: {last_name, birthday} -> {person_id}
- Not FD: {last_name, birthday} -> {first_name}
Normal forms:
All attributes can only contain single values, so the Table is in First normal form.
Looking at the FDs, there are two candidate keys: 1) {person_id}, 2) {first_name, last_name}
- The only non-prime attribute is {birthday}.
- The attribute {birthday} is not FD on part of CK 1 (which is impossible anyway, since there is only 1 attribute in CK 1)
- The attribute {birthday} is not FD on part of CK 2 (i.e. there is no FD {first_name} -> {birthday} or FD {last_name} -> {birthday})
Therefore, this Table is in Second normal form.
S transitively determines T when there exists an X such that S -> X and X -> T and not(X -> S)
- Let S = CK1 = {person_id} and T = {birthday}. The only X such that S -> X and X -> T is when X = {first_name, last_name}. However, then also X -> S holds. Therefore, S non-transitively determines T.
- Let S = CK2 = {first_name, last_name} and T = {birthday}. The only X such that S -> X and X -> T is when X = {person_id}. However, then also X -> S holds. Therefore, S non-transitively determines T.
- Therefore, this Table is in Third normal form.