Possibly the easiest question ever asked

Rob500

Registered User.
Local time
Today, 14:26
Joined
Mar 19, 2007
Messages
10
This is probably blindingly obvious but I'm unsure about it.

We'll refer to three tables, call them Table X, Table Y and Table Z.

Basically, I have a database with 10 tables. Table X links to Table Y via the Primary Key. Another field in Table X has a relationship with the Primary Key in Table Z (a foreign key).

Now, does the field in Table X that has a relationship with the primary key in Table Z need to be the primary key as well?

Put another way, does Table X need two primary keys?
 
One table => ONE primary key (PK)

The other key field in table X is referred to as a foreign key (FK) and should have the same name as the PK in table Z, but instead of being autonumber it will be a Long Int datatype and probably should have null as the default value.

TableZ
Z_ID (auto, pk)
zfield1
zfield2
etc

Table X
X_ID (auto,pk)
Z_ID (LongInt, fk)
xfield2
xfield3
etc
 

Users who are viewing this thread

Back
Top Bottom