View previous topic :: View next topic
|
Author |
Message |
simmimahajan
New User
Joined: 27 Mar 2007 Posts: 30 Location: USA
|
|
|
|
I was asked what is the use of foreign key?
All I could answer is
Foreign key is primary key of another table.
Foreign key-primary key defines a relational join and relational join is nothing but merging attributes from two or more tables.
But then the next question was we can perform join on two tables and we do not require foreign keys to join tables. So what is main reason for having foreign keys. The interviewer also said that we can have a table structure without foreign keys. EDS has it's databse with no foregin keys.
Can somebody give me tell me the exact purpose of foregin key other than what I know?
Thanks,
Simmi |
|
Back to top |
|
|
bharath454
New User
Joined: 28 Sep 2006 Posts: 1
|
|
|
|
With the relation between Primary key and Foreign key, we can achieve Referential integrity(Insert,update and delete).
I think I have answered your question to some extent. |
|
Back to top |
|
|
simmimahajan
New User
Joined: 27 Mar 2007 Posts: 30 Location: USA
|
|
|
|
i think yes..all it boils down to is to eastablish relationship betn two tables you use foreign key..may be the question tht followed were just to confuse..
thnx for all your help |
|
Back to top |
|
|
shane
New User
Joined: 17 May 2007 Posts: 11 Location: Phoenix,Arizona
|
|
|
|
Hi,
The Foreign is the field which contains the data that exist in the primary key field of the Master Table.
I think this gives u simple idea about Foreign Key.
The interviewer asked rest things to test you more n confuse you. |
|
Back to top |
|
|
simmimahajan
New User
Joined: 27 Mar 2007 Posts: 30 Location: USA
|
|
|
|
Thanks Shane. |
|
Back to top |
|
|
|