Here are the STK projects' SQL coding standards. Please, follow these guidelines if you want to contribute.
Indenting and Line Length
Use an indent of 1 tab, 4 spaces long.
It is recommended (but not mandatory) to keep lines at approximately 75-85 characters long for better code readability.
Characters case
Use UPPERCASE for:
- SQL commands
- Builting functions
- information_schema tables and columns
Use lowercase for all identifiers (variables, tables, columns…). The only exceptions are informative tables in meta database, whose identifiers style should be as similar as possible to the information_schema. Please, write information_schema lowercase.
Never create identifiers likeThis or LikeThis.
Index names
Always use explicit names.
UNIQUE indexes have a unq_ prefix. Non-UNIQUE indexes have a idx_ prefix. Foreign Keys have a fk_ prefix.
After the prefix, the name of an index must be followed by the names of its columns, separated with one underscore. This leads to long names, but having a clear, general rule is good when you need to ALTER a table.
Prefixes
All identifiers which may be visible from user's SQL, and does not live in a specific database (like tables), must have a prefix.
STK base prefix is: __stk_
Currently used sub-prefixes are:
- u_ (STK/Unit)
- d_ (STK/DBUG)
- t_ (STK/Type)
Complete prefixes look like: __stk_u_