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? OrCustomerID
?naming of other database objects like views (
CustomerView
vs.vwCustomers
), stored procedures (just be sure to avoidsp_
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.
精彩评论