Mark

You'll get a lot of differing opinions on this subject... here are my 
preferences:

1) Name the table, itself, as singular - makes the SQL statements 
more readable (English-like)

      Event instead of Events, Category instead of Categories, etc.

3) Make the column names as concise and descriptive as possible

      ProgramID, Description, LastName, CreditCardNumber

4) Underscores and/or Caps are a personal preference

5) Do *Not* include any repetition of the table name in the column 
name, except:

     The Primary Key contains its Table name

     A Foreign Key Contains its Table name


       Department
       DepartmentID   Integer Identity Primary Key,
       Name
       Phone
       AnnualBudget


       Employee
       EmployeeID     Integer Identity Primary Key,
       DepartmentID   References Department
       Name
       Phone
       Salary

6) Do *not* include, in the column name,  any reference to the type 
of field: int, char, text, etc.

    It is not unusual for field types to be changed over time, for 
example a varchar field is
    changed to a text field.  Why make the programmer change all his 
programs, documentation,
    operating procedures, etc., *just* because the field *type* has changed?

7) When you reference a column, use the table name as a qualifier. 
This makes a concise, readable
    query:

     SELECT

        Employee.Name, Employee.Phone, Employee.Salary, 
Department.Name, Department.Phone

     FROM

        Employee LEFT OUTER JOIN

        Department ON Employee.DepartmentID = Department.DepartmentID

As opposed to:

     SELECT

        Emp_chr_Name, Emp_chr_Phone, Emp_mon_Salary, Dep_chr_Name, Dep_chr_Phone

     FROM

        Employee LEFT OUTER JOIN

        Department ON Emp_fk_DepartmentID = Dep_pk_DepartmentID

I use the above conventions and have found them to yield efficient 
and readable code (and documentation).

The readability is especially important for use by lay people when 
creating Ad Hoc queries/reports or communicating their needs to 
programmers... the database becomes a major asset of the *entire* 
enterprise.

HTH

Dick


At 10:52 AM -0800 12/21/01, Mark Smeets wrote:
>So, a general question,
>
>When dealing with databases, how do you name your columns?
>
>Example: Table Name: Events
>Column(s): Start, End, Info
>
>Would you name it like this
>(a)Start, End, Info
>(b)eStart, eEnd, eInfo
>(c)cStart, cEnd, cInfo
>(d)or something completely different
>
>(the c stands for column)
>
>This doesn't have to be answered over the list, private email is good too.
>Just curious as to what others do.
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to