Use the DB stored procedures, instead of raw SQL
Document what each stored procedure is doing