3 Ways of Applying Complex Constraints on MySQL

The comparison of check, trigger and application code

ecently I am involved with a project where I have to develop a department management tool, to which, I have to apply some constraints.

For instance, some simple rules are

  1. The parent id has to be chosen only from the existing department IDs.
  2. If a department ID has been used as a parent ID by some department, then it’s unable to be deleted until the usage has been removed.