October 22, 2014 at 8:40 am
Need help in understanding Foreign key and primary key and how to use them in a table
Thanks
October 22, 2014 at 9:44 am
Those are the fundamental building blocks of relational databases. A primary key uniquely identifies a row within a table. A foreign key is used to relate one table to another, usually through the primary key, but it can also be through unique constraints (similar to primary keys, but a little different). These terms are defined in more detail in the link above.
The SQL Server documentation includes information on how to create a primary key and a foreign key. You can also see additional links there for modifying or dropping primary & foreign keys.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 22, 2014 at 10:08 am
Grant Fritchey, thanks very much but i can't see the link
October 22, 2014 at 10:28 am
Where it says "relational databases" is a link. There is another at "primary key" and "foreign key" in the second paragraph.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 22, 2014 at 10:32 am
I always thought it was more like:
Those are the fundamental building blocks of relational databases. A primary key uniquely identifies a row within
the databasean individual table. A foreign key is used to relate onedatabasetable to another, usually through the primary key, but it can also be through unique constraints (similar to primary keys, but a little different).
October 22, 2014 at 10:35 am
patrickmcginnis59 10839 (10/22/2014)
I always thought it was more like:Those are the fundamental building blocks of relational databases. A primary key uniquely identifies a row within
the databasean individual table. A foreign key is used to relate onedatabasetable to another, usually through the primary key, but it can also be through unique constraints (similar to primary keys, but a little different).
Oh fudge.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 22, 2014 at 10:35 am
Edited it. Not sure where my brain was.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply