I have a legacy table that has as a part of its natural key a column named <table_name>_IDENTIFIER
and it seems like it would be confusing to create a surrogate key named <table_name>_ID
or ID
so I'm leaning towards naming it SURROGATE_KEY
. All my other tables use the <table_name>_ID
syntax. Any better suggestions?
views:
26answers:
3Don't call it SURROGATE_KEY. That is meaningless in any other context. I'd stick with <table_name>_ID
. Yes it's a little confusing. But, given your established convention, anything else would be confusing too.
I might suggest that you go with your standard: <table_name>_ID
Eventually, the legacy table will not be the driving force, and it will be the IDENTIFIER column that will look odd, which is what you want, as opposed to that - 'oh yeah, i need to use surrogate_key for that thing instead of id...' moment.
First, I would not include the table name in my columns. A column is an attribute which requires the context of the entity to which it belongs. Having a "name" for example without the context to which it belongs is of no use. You need to know it is a Person's name or a Company name etc. and you have that in the name of the entity itself. Thus, I would not prefix columns with the name of the table in which it is declared.
That leaves you with choices like "Id", "Key", "SurrogateKey", or perhaps "SystemId" which are all equally vague. At least "SurrogateKey" describes what it is which is a bonus. That name will make sense to a DBA but perhaps not a developer (although they should understand the concept). Of those choices, I'd be inclined to use "Id" and find a way to change <table_name>_Identifier
to something more descriptive.