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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary & Foreign Key Naming Consensus?

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
I am currently experiencing the problem 'Insufficient key column information for updating or refreshing' when I try & modify data via ADO. This is a known problem with Microsoft ( MDAC, & they state the reason is 'if the recordset, based on a SHAPE command, joins two tables where the primary key of one table has the same name as a column name of the other table'. I currently name primary & foreign key fields with the same name (i.e. BRSID). If I change the foreign key of this field to BRSIDL the error is resolved.

However, what is the consensus as to the naming of primary & foreign keys? James Goodman MCP
 
i doubt you'll get a consensus :)

if naming them the same causes problems, people will do otherwise

naming them the same is useful for natural joins (sorry, no idea if sql server supports natural joins)

me personally, i like the idea of naming the primary key ID and then the foreign keys have the referenced table name, or portion thereof, as part of the name

e.g. employee table as "id" as primary key, timesheet table has "emplid" as foreign key, and then joins will read as follows:

... on employee.id = timesheet.emplid


rudy
 
For what its worth I agree with Rudy. It makes reading the code easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top