- Follow the naming in: Google Java Style Guide
- Use a
new
prefix for factory methods (e.g.newFoo()
instead ofcreateFoo()
)
- snake_case
- Use singular names, eg:
user
instead ofusers
- Spaces, no tabs
- Line break on SQL keywords "select, join, where, having, group by, order by"
- Line continuations are 4 space indented
- Favor using a PK column that is a number
- Use
id
for the name of the primary key column- Good:
user.id
- Bad:
user.user_id
- Good:
- Foreign key columns are named after the table and column they refer to, eg:
<table_name>_<column_name>
- EG:
user_id
would reference theid
column of theuser
table. - If needed a prefix can be added if there are multiple references to the same table, eg:
user_ban.muted_user_id user_ban.banned_user_id
- EG:
select * from user_ban ub
join users u on u.id = ub.user_id
where ub.expires_on > now()
and ub.some_column = 'example';