Skip to content
This repository has been archived by the owner on May 8, 2019. It is now read-only.

Database Design

Guo Yunhe edited this page Jun 15, 2016 · 3 revisions

Column Order Rules

  1. id (primary key)
  2. id-like columns. For example, parent_id and locale columns in translation tables.
  3. content columns for mass assignment. Like type, name, description, email, address, website, image_id
    1. Important columns placed first. Like type, name, description, image_id.
    2. Non-important columns placed later. Like website, facebook, phone.
    3. Group by relation. For example, city_id, address, latitude and longitude can be together.
  4. protected columns: parent_type, parent_id, user_id
  5. automatically generated columns: like_count, view_count
  6. timestamps

Example: place table

id

type

image_id

city_id
address
latitude
longitude

email
phone
website

facebook
google_plus

user_id

like_count
view_count

created_at
updated_at
deleted_at