467,134 Members | 944 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

Foreign Key Type for "uniqueidentifier"

Expert Mod 16PB
SQL Server 2000.

It's all in the title really. I have checked in quickbooks and done a quick search but time is critical just now.

I will continue to explore other avenues, but if anyone knows how an FK field should be defined so that it can link into a "uniqueidentifier" GUID field that would be helpful.
Nov 27 '08 #1
  • viewed: 14746
7 Replies
Expert Mod 16PB
I did some further searching and I think the answer is that the type is actually the same ("uniqueidentifier"), but the default value and general setup are just done differently (Table ROWGUID not set for instance).

Assuming that to be the case, here's another question :
If I have two tables linked on a field (in this case HdrID - the unique ID of the header record) is it necessary for me to create an index of this field in the Detail record if I already have a Relationship Constraint set up?
Table Name=[tblTHSOPH] (AKA Header)
Expand|Select|Wrap|Line Numbers
  1. Field       Type          IndexInfo
  2. HdrID       uniqueidentifier  PK
  3. Various Header related fields...
Table Name=[tblTHDSOP] (AKA Detail)
Expand|Select|Wrap|Line Numbers
  1. Field       Type          IndexInfo
  2. DtlID       uniqueidentifier  PK
  3. HdrID       uniqueidentifier  FK
  4. Various Detail related fields...
Nov 27 '08 #2
Expert 4TB
That depends how frequently you use the field in SQL directly. Indexes has negative effect during hugh data loading.
Nov 29 '08 #3
Expert Mod 16PB
Thanks Debasis.

I suppose I should have been clearer (although your answer implies yes I do). Does the index need to be specified separately, if you require it to be indexed? Put another way, does the relationship automatically create an index?
Nov 30 '08 #4
Expert 4TB
Yes the indexes need to be created separately. Specifying the relationship based on PK & FK will not do that automatically for you.
Dec 1 '08 #5
Expert Mod 16PB
Thanks for that Debasis.

All sorted cheers :)
Dec 1 '08 #6
Expert 2GB
Yes the Index needs to be created seperately on the foreign key column ie on the HdrID of Details table.

But Yes an Index gets created automatically when you define a PRIMARY KEY or UNIQUE KEY on any column of a particular table.

Index does not get created automatically for any relationship defined.

Hope this helps!!
Dec 5 '08 #7
Expert Mod 16PB
Yes. Thanks Amit :)
Dec 5 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by ewpatton@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.