Finding primary key given relation and functional dependencies

829 views Asked by At

Given the relation:

Competitor(PID, EventName, Pname, TeamName, TeamCoach, EventDate, TeamRating)

And the functional dependencies:

PID -> Pname, TeamName, TeamCoach 
TeamName -> TeamCoach 
EventName -> EventDate 
TeamName, EventName -> TeamRating 

Based on my knowledge I believe the primary key is {PID, EventName, TeamName}

The answer provided says that the primary key is {PID, EventName}

Either I am wrong (which is likely) or the answer provided is wrong.

If you could tell me which is right and the method of how you found it, that would be great.

1

There are 1 answers

1
dijkstra On

Your answer is superkey key and it can be qualified as primary key. However, it is not the best answer. The best answer is {PID, EventName}. Your answer is not cadiate key.

You can find candidate key by finding closure of it. If it equals {PID, EventName, Pname, TeamName, TeamCoach, EventDate, TeamRating}, it is candidate key. You can find finding closure algorithm in this site: http://www.cs.sfu.ca/CourseCentral/354/jpei/slides/ClosureDecomposition.pdf

The closures of {PID, EventName} :

C={PID, EventName}

Function: PID -> Pname, TeamName, TeamCoach 
C= {PID, EventName, Pname, TeamName, TeamCoach }

Function: EventName -> EventDate
C={PID, EventName, Pname, TeamName, TeamCoach ,EventDate}

Function: TeamName, EventName -> TeamRating 
C={PID, EventName, Pname, TeamName, TeamCoach ,EventDate,TeamRating}