Move apidb backends to a consistent whitespacing format

The backend files were a mix of 3 space idents and 2 space indents,
often in the same function. This commit moves to a consistent 2
space indent and makes a few else clauses use a consistent format.
Reformat apidb backend SQL statements for clarity

No changes in the SQL, just whitespace and caps changes
Rephrase some SQL queries

No changes in meaning, just consistent AS names.