Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 same column name in two tables

Author  Topic 

nic
Posting Yak Master

209 Posts

Posted - 2004-06-25 : 15:18:07
Hi,
I have two different tables which track information about houses. In table 1 (Dwellings) I have a column named "RoofType". It holds info about the dwelling's roof. I also have another table named DwellingImprovements which stores info about renovations. In it I have a column also named "RoofType". It stores info about the type of roof improvement.

It is somewhat confusing to have the same column name in two different tables. Would it be a better design to name it something like "ImprovRoofType" so you can see that they are different? But this is somewhat redundent though because it is in the Improvement table (should all columns in that table have the prefix Improv?)

In general, I try to keep column names different but after awhile there are so many items in so many tables that it is hard to be unique in all cases.

I'm curious how others with even larger database handle this dilema.

Nic

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-06-25 : 15:24:12
I always keep the columns name the same. It would way too confusing by always changing it. I know I am not a huge help, but that is what I do.

Brenda
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-25 : 15:24:50
Generally (for me), if the data is the same (same definition) then I will use the same name, if it is different (diff. definition) then I use a different name. You want to be descriptive but brief. If you get confused then change the column name. You probably don't need to add 'improv' to all of the columns, maybe shorten it to 'i' or 'im' or 'imp' if you want to keep them consistent.

Corey
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-25 : 15:25:59
I name foreign keys like this as <tblname>_id - <tblname> will be descriptive of what the table contains.
Only has a problem when there are multiple references from the same table.

If your two columns are referencing the same table then I would put something like improv in the name - but I guess it's different tables from your question.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-06-25 : 15:50:06
I have a (unique if poss.) prefix, the "nickanme" for the table, for all the columns in a table.
Then I Suffix this with either a House Style code (e.g. ID = Identity column) or a Descriptive name for the column.

For me this makes JOINs and the like much more obvious.

I described this further in this thread, if you are interested:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=36629&SearchTerms=nickname

Kristen
Go to Top of Page
   

- Advertisement -