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
 General SQL Server Forums
 Database Design and Application Architecture
 Naming Columns

Author  Topic 

reliabox-mike
Starting Member

1 Post

Posted - 2011-06-20 : 22:12:09
Is there a standard for naming the columns of a table? A coworker and I are going back and forth on appending the full table name to the column or not. example

table - widget

column - widget_name
or
column - name

what one is better?

Windows Hyper-V VPS at Reliabox.com

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-20 : 22:18:55
Please do not append the table name to each column. It serves no purpose. Just be consistent with whatever you choose.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

BaggaDonuts
Yak Posting Veteran

52 Posts

Posted - 2011-06-29 : 03:50:00
Here's what I do:

Table names: Use Pascal Casing. Make the table name singular. Ex: Product, ProductAttribute. Don't do things like prefix it with "t_". When integrating with something like Entity Framework, your object would then be called a "t_Product". Singular table names are also very beneficial when using Entity Framework. So using my standard, the EF object would be named "Product." Nice to keep it consistent across layers.

Table Columns: Use Pascal Casing. For your primary key column I prefer to have the table name followed by "Id." If you have a human readable identifier as well, I call those the table name followed by "Name." So, for the Product table example, some columns might be: ProductId, ProductName, ReleaseDate.
Go to Top of Page

khan_shahidnoor
Starting Member

2 Posts

Posted - 2011-07-13 : 03:12:32
how update tabe from another table
Go to Top of Page

khan_shahidnoor
Starting Member

2 Posts

Posted - 2011-07-13 : 03:13:37
how to update table from another table in sql server 2005
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-13 : 12:42:31
khan, open a new topic for your question. It makes no sense to hijack this thread when your question isn't even related.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-07-16 : 11:25:45
Yes. ISO-11179 Meta Data Standards. For a readable explanation get a copy of my SQL PROGRAMMING STYLE. I also included the results of research that AIRMICS did for the DoD. The basic idea is to name a data element for what it is by its nature and name it completely. DO NOT name it by where it is or how it is used in one place. They are global in the whole schema, and better yet universal (UPC, ISBN, VIN, etc). The general format is:

[<role>_]<attribute>_<attribute property>

So we write "widget_name", "widget_size", etc. and perhaps when many column are drawn from the widget domain, "primary_widget_name", "secondary_widget_name" and so forth. We never use PascalCase or camelCase as they are physically harder to read (your eyes jump to upper case letter).

Some companies and US government now require the ISO-11179 Standards and are building data dictionaries, etc. for it.


--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-07-19 : 00:09:56
^^ More spam ^^
Go to Top of Page
   

- Advertisement -