I have few doubts which I want to clear regarding referential constraints.
Lets say I have three tables
a) Users has following columns:
In Users table I have set usr_id as the primary key.
b) Gallery has following columns:
In Gallery table I have set gallery_id as the primary key.
c) Images table has following columns:
in Images table I have set img_id as the primary key.
now my doubt is I want to link these tables using foreign key.
Users -> Gallery -> Images
which is the best column in gallery to be a foreign key to the Users table.
In Users table usr_id is my primary key and in gallery it is gallery_id.
So should I link usr_id of user table with the usr_id in Gallery table ?? i m little confused.. because by default shouldn't it be the primary key that gets linked ??
..:: peace ::..