2 ms·
My SQL style guide is quite a bit different from this: * Use consistent and descriptive identifiers and names. * Make judicious use of white space and indenta
by wvenable 10y ago
My SQL style guide is quite a bit different from this:
* Use consistent and descriptive identifiers and names.
* Make judicious use of white space and indentation to make code easier to read.
* Try and use the same column/table naming convention as your programming language. If you language uses camelCase, use that. If it all possible, names should be the same everywhere to prevent confusion.
* Table names should always be in the singular: "Person" instead of "People", "Invoice" instead if "Invoices". This removes all pluralizing ambiguity and makes sense when mapping to class names, etc.
* Concatenate two table names together to create the name of a relationship table (especially in the case of many-to-many) unless a more appropriate name makes sense.
* Use TableNameId as the primary key column name.
---
* Do not use descriptive prefixes or Hungarian notation such as sp_ or tbl.
* Do not plurals -- don't even use collective names
* Avoid quoted identifiers
* Avoid underscores -- except for use a poor-mans namespacing
* Avoid simply using id as the primary identifier for the table.
* Avoid aliasing as much as possible unless joining the same table multiple times. In that case, use a descriptive name. Never use short one or two character aliases.
* Avoid putting keywords in all caps -- use an editor with syntax highlighting instead.