Natan
2004-06-24 23:05:16 UTC
Hi.. I would like an opinion about this silly thing:
In my office, we use PK/FK prefixes to indicate Primary/Foreign keys.
Before working there, I aways used "ID" to indicate these columns.
so, instead of having a User table with pkUser and all other tables
having fkUser, I like the User table to have an user_id and other tables
have the user_id field as well. If i'm in table "messages" and have a
"user_id" field, of course it's a foreign key because the primary would
be the "message_id" field.
I think this second scheme is more obvious for the same reason that I
name a field "Name" instead of "strName", or "active" instead of
"bitActive"... for me it just doesn't matter the type of data or the
constraints it has in the name of the field. If I need to use a table a
never worked before, I'll just check it with Query Analyser or any other
tool in another database, and it's all there, constraints and data types.
My friends agree about "strName" being stupid, but "pk/fk" is stuck in
their minds as if it would bring the company to the chaos if we use
"id". They tell me it's "microsoft recommendation".. Well, sql server
internal and example tables use "id" for "ids" and it seems to work okay =)
I would like to know the opinion of other users about this, and what are
the pros/cons about "ids" and "pks".
Thanks =)
In my office, we use PK/FK prefixes to indicate Primary/Foreign keys.
Before working there, I aways used "ID" to indicate these columns.
so, instead of having a User table with pkUser and all other tables
having fkUser, I like the User table to have an user_id and other tables
have the user_id field as well. If i'm in table "messages" and have a
"user_id" field, of course it's a foreign key because the primary would
be the "message_id" field.
I think this second scheme is more obvious for the same reason that I
name a field "Name" instead of "strName", or "active" instead of
"bitActive"... for me it just doesn't matter the type of data or the
constraints it has in the name of the field. If I need to use a table a
never worked before, I'll just check it with Query Analyser or any other
tool in another database, and it's all there, constraints and data types.
My friends agree about "strName" being stupid, but "pk/fk" is stuck in
their minds as if it would bring the company to the chaos if we use
"id". They tell me it's "microsoft recommendation".. Well, sql server
internal and example tables use "id" for "ids" and it seems to work okay =)
I would like to know the opinion of other users about this, and what are
the pros/cons about "ids" and "pks".
Thanks =)