开发者

What are naming conventions for SQL Server? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I need to create database for SQL Server, what kind of naming conventi开发者_JS百科on I should use?

1) Table names could be : customer, Customer, CUSTOMER

2) Field names could be : customer_id, CustomerId, CustomerID, CUSTOMER_ID, customerid, CUSTOMERID and so on...

Is there any official suggestion for naming conventions or what is most common way to name tables and fields?


There are a lot of different and differing standards - pick the one that makes most sense to you and then stick to it - that's the most important part. Have a standard and live up to it!

Things to consider are:

  • naming the tables - singular (Customer) vs. plural (Customers)
  • naming the tables - with or without prefix, and if with: what prefix? (Customer vs. tblCustomer vs. T_Customer vs. something else entirely)
  • naming of columns - any defaults? E.g. ID for the primary key? Or CustomerID?

  • naming of other database objects like views (CustomerView vs. vwCustomers), stored procedures (just be sure to avoid sp_ as your prefix! Reserved by Microsoft), user-defined functions (GetData vs. fnGetData vs. func_GetData)

There's no "official best practice" on this - different standards suggestions have their merits, but you're basically free in choosing what you want to use for your own company / your own doings.

Just google or bing for "sql server naming conventions" and you'll find a gazillion of different standards. Pick the one you're most comfortable with, or come up with your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜