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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Shoud i create a foreign key constraint

Author  Topic 

zubairmasoodi
Starting Member

35 Posts

Posted - 2011-02-08 : 12:52:14
Hi

I have a very simple Question and i know experts here will give me an instant reply.

I have a table UserInfo withe the following columns

UserID P.K
UserName
Password
CountryID

And an another Table Country with the following columns

CountryID P.K
CountryName

Will it be advisable to add a foreign key constraint to User table On (CountryID) column which points to CountryID of Country table

If Yes , why?
If Not , Why not? and what is the alternate way, or there should be no relation between the two.

All replies are deeply appreciated

Thanks

New SQL Server Programmer



russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-02-08 : 13:35:50
Yes.

Any place you CAN have a foreign key you SHOULD have one.

Why is easy. The most important thing is data integrity -- having good data.
Go to Top of Page
   

- Advertisement -