Whenever I design a database, I usually question if there's a easiest way of naming a product during my database. Quite frequently I request myself the next questions:
- Should table names be plural?
- Should column names be singular?
- Must I prefix tables or posts?
- Must I use any situation in naming products?
What are the suggested recommendations available for naming products inside a database?
I suggest looking at Microsoft's SQL Server sample databases: http://codeplex.com/SqlServerSamples
The AdventureWorks sample utilizes a very obvious and consistent naming convention that utilizes schema names for that organization of database objects.
- Singular names for tables
- Singular names for posts
- Schema reputation for tables prefix (E.g.: SchemeName.TableName)
- Pascal casing
Ok, since we are hitting the scales with opinion:
In my opinion that table names ought to be plural. Tables really are a collection (a table) of organizations. Each row signifies just one entity, and also the table signifies the gathering. And So I would call a table of human organizations People (or Persons, whatever you admire).
For individuals who want to see singular "entity names" in queries, that is what I'd use table aliases for:
Choose person.Title FROM People person
A little like LINQ's "from part of people choose person.Title".
For 2, 3 and 4, To be sure with @Lars.
- No. A table ought to be named following the entity it signifies. Person, not persons is when you'd make reference to whomever among the records signifies.
- Again, same factor. The column FirstName must not be known as FirstNames. Everything is dependent on what you would like to represent using the column.
- Yes. Situation it for clearness. If you want to have posts like "FirstName", casing can make it simpler to see.
Ok. Thats my $.02
Sometimes inside a database support team with three DBAs and our considered choices are:
- Any naming standard is preferable to no standard.
- There's no "one true" standard, everybody has their preferences
- If there's standard already in position, utilize it. Don't create another standard or muddy the present standards.
We use singular names for tables. Tables are usually prefixed using the title from the system (or its acronym). This really is helpful when the system complex as possible alter the prefix to group the tables together realistically (ie. reg_customer, reg_booking and regadmin_limits).
For fields we'd expect area names to become range from the prefix/acryonm on the table (i.e. cust_address1) and that we also prefer using a standard group of suffixes ( _id for that PK, _compact disc for "code", _nm for "title", _nb for "number", _dt for "Date").
The title from the Foriegn key area ought to be the just like the main key area.
Choose cust_nm, cust_add1, booking_dt FROM reg_customer INNER JOIN reg_booking ON reg_customer.cust_id = reg_booking.cust_id
When creating a new project, I'd recommend you create all of the preferred entity names, prefixes and acronyms and provide this document for your designers. Then, once they decide to produce a new table, they are able to make reference to the document instead of "guess" exactly what the table and fields ought to be known as.
I am also towards a ISO/IEC 11179 style naming convention, observing they're recommendations instead of being prescriptive.
"Tables are Collections of Organizations, and follow Collection naming recommendations. Ideally, a collective title can be used: eg., Personnel. Plural can also be correct: Employees. Incorrect names include: Worker, tblEmployee, and EmployeeTable."
Of course, you will find exceptions to rules e.g. a table which has exactly one row might be better having a singular title e.g. a config table. And consistency is very important: check whether you shop includes a convention and, if that's the case, abide by it if you do not enjoy it then perform a business situation to be transformed instead of being the lone ranger.