Find Prime and Non – prime attribute from attribute closure:
Before seeing the chapter please follow the previous chapter: Concept of Attribute Closer, Find Super and Candidate Key from Attribute Closer.
Example 1:
A → R and A are minimal then attribute A is Super key and Candidate key also.
Calculating Candidate Keyand prime and non-prime attributes
PA (Prime Attribute) = {A,
CK (Candidate Key) = {A
Now we check from FDs where we will get prime attribute (PA) at the right-hand side of FD. If we get any PA to replace it with its left-hand side.
Why we do these because
We replace A with BC if A is key then BC also a key.
PA = {A, B, C}
CK = {A, BC}
So, A, B, C is Prime Attribute but there is no PA at left hand side of rest of FDs.
So, PA = {A, B, C} and CK = {A, BC}
Non-prime attribute (NPA) = {D, E, F}
Example 2:
CK = AB, PA = A, B
Now we search for PA at FDs on the right-hand side if present then replaces it by its left-hand side F → A (Here find PA – A at this FDs) i.e. we can replace A by F.
Check for Candidate Key (CK)
So, FB is SK and CK also.
CK = {AB, FB}
PA = {A, B, F}
Now again find PA at FDs.
We get
So, we can put E in place of F
Check for CK
So, EB is SK and CK also.
CK = {AB, FB, EB}
PA = {A, B, F, E}
Now again find PA at FDs
Check for CK
So, DB is SK and CK also
CK = {AB, FB, EB, DB}
PA = {A, B, F, E, D}
Again we find Prime Attribute – D at C → D
Check for CK
So, DB is SK, CK
CK = {AB, FB, EB, DB}
PA = {A, B, F, E, D, C}
If we put again AB → C
CK and PA is final and NPA = ɸ = { }
If the only Relation is given with no FDs like R (ABCDE) we can make one trivial FD.
CK = {ABCDE}, PA = {A, B, C, D, E}, NPA = ɸ = { }