Wednesday, October 24, 2007

Constraint Naming Conventions

Doesn't really matter how you feel about this as long as you are consistent. I picked this up from comments on Dizwell's site and I basically like it. The only thing I change is the use of table names except in the case of foreign keys.

  • Each table has a full name (employee) and a short name (emp) of three or four characters.
  • Each PK is named PM_short_name, so PK_EMP.
  • Each FK is named FK_parent_short_name_child_short_name and if more than one required, an additional sequence number is added as a suffix. So, FK_EMP_DEPT.
  • Check constraints are CHK_short_name_column_name - if at all possible. Alternatively, CHK_short_name_reason if it fits. Example, CHK_EMP_NAME or CHK_EMP_NAME_PRESENT.
  • Unique constraints are UQ_short_name_column where possible or UQ_SHORT_NAME_reason. For example, UQ_EMP_EMAIL.

Tuesday, October 16, 2007

Power Architect is the best ERD drawing tool I've found

I spent 3 days trying everything out there and Power Architect came out the winner:

http://www.sqlpower.ca/page/architect

Free, simple, saves ERD as PDF, reverse engineers, Java based so it will run on anything. A little buggy here and there but overall a great tool.