Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rohan_chikhale
Starting Member
7 Posts |
Posted - 2009-05-05 : 13:52:21
|
Can i use non-primary key as foreign key...will it affect the performance and can cause headache of maintaing the relationships....?plz clear my doubt....thank you...Rohan Chikhale |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2009-05-05 : 14:23:49
|
A foreign key does not have to reference a primary key constraint in the parent table. It can reference a unique constraint too. It will not cause any extra negative performance. There isn't any headache in maintaining relationships, so I'm not sure what you are referring to with that question.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong." |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-05-05 : 15:20:39
|
There is over head associated with foreign keys, yes. But, I'd much rather have correct data (hardware is cheap) :) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-05-05 : 15:26:54
|
I would agree the overhead is minimal and I suggest one always uses RI to it's fullest. But, you can notice a difference in speed when, for example, inserting million(s) of rows into a table with a foreign key reference to another table that also has millions of rows. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
rohan_chikhale
Starting Member
7 Posts |
Posted - 2009-05-06 : 01:22:21
|
k freinds.....thank you for clearing my doubt.....i was confused whether to go for the primary key or non-primary key of the parent table ......Rohan Chikhale |
|
|
|
|
|