November 26, 2003
Database Design
When designing a database, use the single version not the plural of the name of the table. For instance, if you have a table that is full of people, call the table, tblPerson, not tblPeople. Why? Well for cardinality reasons, when deciding how to normalize the database, this convention gives a clearer tip to the relationship being either one to one, one to many, or many to many. For example, let's say we have a database, with a couple of tables, tblCustomer, tblDemographic, and tblVisit. One customer can have many visits, and a customer can have many demographics. The convention makes it just a little bit clearer when discerning the database schema.
The other item is to prefix database tables.
- For tables, try using tbl
- For views, try using vw
- For queries, try using qry
- For stored procedures, try using sp
These prefixes do a couple of things, when you are long gone and at that 6 figure job you deserve :), individuals reviewing your code, can easily determine what they are looking for, when it breaks. Also reserved words will never affect your application, who's going to make a reserved word tblfile vs file?
I completely agree with not using reserved words, and prefixing everything. Personally, I will also use...
tlkp -- prefix for lookup tables
tlnk -- prefix for many-to-many join tables
This saves time when going back to old databases, trying to remember which tables hold "real data" and which were just a place to store commonly used lists (states, zip codes, whatever).
However I will often switch between the plural and singular version of a word for my table name, based on what makes the most sense.
Example:
tlkpZipCodes (plural) -- it is, in fact, a list of zip codes. There is no relationship here. It's purely storage.
tblMessageBoard (singular) -- this is my message board, containing the message content, and probably some data like who posted the messages, dates they were posted, originating IP address, etc.
Also, since several databases use "sp" as their prefix for system (built-in) stored procedures, sometimes I will come up with another prefix for them. Usually something pertaining to project name. This is just so I can tell my stored procedures apart from the preexisting ones.
By the way...hello, I'm Nolan. I found your blog off a link from http://www.fullasagoog.com/ a few days ago.
Hi Nolan!
Posted by: Brian LeRoux at November 28, 2003 1:55 AMFinally passed the test
Managing in light of McGregor's Theory X and Theory Y
CMMI
Kicking HIT Leadership Up a Notch
That's just some mumbo jumbo project management BS
Outcomes - The tactic to get to the strategy
Nurse Call, VOIP, and Wi-Fi: Its just cool when things come together!
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
August 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
November 2005
October 2005
September 2005
August 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
Joel on Software
David Ross
Edward Prevost
Martin Fowler
The Health Care Blog
The Tales of Hoffman
The Business Word
Medical Rants
Christina's Considerations
Paul Levy
HIS Talk
Appropriate IT
Candid CIO
RSS feed




