Table names

Table names should correlate with model's classes names.

SQL code layout: Here's a sample of how ideally SQL code should look. Note where the lines break, the capitalization, and the use of brackets.


Examples:

SELECT field1 AS something, field2, field3
FROM (table a, table b)
WHERE (this = that) AND (this2 = that2)

This is valid too however:

	  	SELECT field1 AS something, field2, field3 FROM (table a, table b) WHERE (this = that) AND (this2 = that2)
		

ALWAYS enclose FROM tables into brackets – for LEFT JOIN compatability in MYSQL 5+.

SQL insert statements: SQL INSERT statements should be written LIKE UPDATE statemnets.

Examples:

# This is not what we want.
INSERT INTO mytable
VALUES ('something', 1, 'else')

# This is correct.
INSERT INTO mytable SET column1='something', column2=1, column3='else'