Naming Convention
in Database
Davis Chen
Agenda
•Global Naming Convention
•Table
•Column
•Constraint
Naming Conventions
+
Consistency
II
Best Practice
Global Naming Convention
• UPPERCASE / lowercase / camelCase /
PascalCamelCase
• Separate with underscore (order_detail)
• Singular / Plural (company not companys)
• Same term for same meaning
• Prefix & Postfix
• Do not use number (1st ,type_4_address,user_2_role)
• Comment
Table
• Relationship
◆user_role , user has many role
◆employee_address , employee has an address
• PK
◆Use id in all table / {table}_id
◆Avoid composite key
• Use Same Term (account / accounting / accounts)
Column
• Same term !!!
◆status,state,code,info,version,checkd ...
◆created_at,updated_at,deleted_at
◆created_user_id,upXXX...,deleXXX...
◆type,category,classification,kind ...
• FK
◆{ref_id} -> user ref company , use company_id
Constraint
• pk_{table}
• fk_{table}_ref_{ref_table}
◆fk_employee_ref_address
• uq_{table}_{column}
• ix_{table}_{column}
• {table}_seq
• tr_{table}_bi(before insert)_XXX
Q & A
~~ Thanks for your listening ~~

Naming convention in_database