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

Naming identity columns

Status
Not open for further replies.

ESquared

Programmer
Dec 23, 2003
6,129
US
I have two lookup tables, MapShopTypes and PaymentTypes. I can't name the tables Shops and Payments because for example, Shops actually contains the list of MapShops that are of type MapShopType.

Now, it is tempting to make the primary key in each TypeID. But I could possibly run into confusion and if I want to use the same name as the key in foreign key columns, I can have a conflict. But I don't like having to say PaymentTypeID and MapShopTypeID every time I need to reference the columns.

I'm wondering if anyone has input for me on what you would do, and how you handle naming in your own databases.

Maybe I'm making a big deal out of nothing...
 
Frankly I'd use PaymentTypeID and MapShopTypeID. They are unambigous and if they need to have foreign keys, you will know what they go with. I try always to make my id names such that I can put them inthe foreign tables with the same names and that lets me know where thay are probably referenced without having to look at the foreign key.

Since I use query analyzer to drag and drop column names when I write sp's and queries, the length doesn;t bother me at all.

Questions about posting. See faq183-874
 
Hmm, thanks for the input.

I will check out dragging and dropping... but for the most part I type everything. The more I type the faster I get at it. I guess the philosophy was that it's like intentionally not programming any autodial buttons on your phone... you're forced to learn the numbers you use most often and then, when you're away from your phone, you can remember them.
 
With my typing if I didn't drag and drop I'd spend forever fixing my misspelled names. My fingers appear to be dyslexic, I know how to spell words, I just can't seem to type them without reversing characters. Besides, if you want to use all the fiedls ina table except one ro two, it is so much faster to drag them all over in one step and delte the few you don't want, than it ever could be to type them.

Questions about posting. See faq183-874
 
That's a good point. In fact, I realize that I have done something silly. Instead of using the object browser, I did

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table'

then copied and pasted from there... blush.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top