Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relationships - Store ID value or Text

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have a couple of tables who have fields that will contain values from other tables.

Just wondering if most people store the ID for the value as an integer or store the actual text as varchar/nvarchar

What is best practice?
 
Not sure exactly what you are askingn, but in relational databases you don't "have fields that will contain values from other tables". Rather, you have a foreign key field that relate to the other table, and the foreign key would have the same data type as the primary key of the related table.
 
Your key can be varchar or integer. Integer is nice because it is easy to incrament and the system will do it for you if you make it an Identity.

But there are times that you would varchar (or other type) as well. It just depends on your situation.

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top