Relations, dependencies and normal form

I have some issues in understanding about relations and dependencies. I will show two examples and what I want to know:

Assume the relation GTX {G,T,X} with the following dependencies:

G,X -> T
T -> X

or this one:

Relation {W,X,Y,Z}:

X,Y -> Z
Z -> W
• So to my question, how do I properly draw a dependency diagram for this kind of relations? (tutorials or/and explanations are much appreciated)
• How do I see what the primary key is? (I know what a pk is)
• In which normal form are the relations?

I have never been able to understand this fully and always got confused by the tutorials I found. I appreciate all answers!

From a set of FDs, you can only infer a set of candidate keys.

A "primary key" is one particular member of that set of candidate keys that you elect to be "primary". And there are no scientific rules that tell you which one you should choose - you can pick just any key and label it "primary".

In your first example, you should end up with a set of candidate keys

{ {T G} {G X} }

In the second example, you should end up with a singleton set of candidate keys

{ {X Y} }

As for how to arrive at the set of keys, you can take a look at https://stackoverflow.com/questions/5735592/determine-keys-from-functional-dependencies/5736174#5736174

The relation what you gave shows that X and Y depends upon Z. So Z should be the primary key in the table with Z,X,Y as columns. Again Z depends upon W. So in another table W should be the primary key and Z should be the foreign key relating to the first table.

• I think you have the notation backwards. X,Y -> Z means that Z depends upon the composition of X and Y. Aug 16 '13 at 21:14