Column Naming

When you’re designing your tables it is important to keep track of the names you’re using for the columns. Don’t just name the ID columns ID. Name them so you’ll know what table the ID belongs to. For example, if you have a music database and you have a table for the Artist, you could name the ID column ArtistID. Try to keep your column names unique throughout the database to minimize confusion about what table you’re referencing. There’s one very important exception to this, however. If your column is a foreign key, keep the name the same as in the origin table. This will prevent future confusion.

Unfortunately, I see databases fairly frequently where the foreign key column has a different name from the name of the origin column. To make matters worse, there’s frequently no explicit foreign key declared, you’re just supposed to know where the link is. For example, in the music database mentioned before, if you have an Artist table and the Primary Key Column is called ArtistID and a table called Album, make the foreign key on the table Album ArtistID. If you lose track of what you’re naming things it is entirely possible to make that column BandID or PerformerID, then when you go back you’ll have little idea what it was intended to reference.

This gets much worse in the business world where the databases are larger and the data more generic. To help keep track of this kind of information, I highly recommend Visio. There are other database diagramming programs out there, but Visio is the one I’ve used most. Having it all laid out in front of you before you begin actually creating the tables can help make sure the design is solid and help you make sure you haven’t made any crazy naming decisions.

This entry was posted in 2008, SQL Server and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>