Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Database Rule

  1. Avoid Hard delete in database, suggestion soft delete
  2. Avoid SELECT * FROM ... in query apps. Please define your column.
  3. EX: l = Location.find_by_sql(:conditions => ["SELECT name, website, city FROM locations WHERE id = ? LIMIT 1", id])
  4. Don’t JOIN different schema database.
  5. Column comparison using in JOIN table must be INT or UUID. Make sure the column is default not null.
  6. Handle possible null value in your app.
  7. Avoid function now() and CURRENT_TIMESTAMP() in where clause. Please generate date on the app side. Cause this function is costly if you running in query.
  8. Ordering data except for pagination purpose must be executed in app.
  9. Consult your new queries, indexing table or may be want to get huge data to DBE team
  10. Instead of using OR for filter values in same column, please use IN. ex: where a in (1,2) ; where a=1 or a=2
  11. Every table must has created_at, updated_at, deleted_at and is_deleted. Those columns used for CRUD and also for soft delete .
  12. Maximum 100 data in where clause IN (data 1 - 100)