Should you enforce constraints at the database level as well as the application level?

In short : database should enforce constraints.

Why :

  1. Easier. For ex. to have a constraint set on a particular data column there is only one place to set it : the column itself. The data might come from various sources but the check is put where the data is finally put to rest.
  2. Integrity. Database should be responsible for the data it hosts. An inconsistent database is as good as no database.
  3. Flexibility. New UI development environments come all too frequently. If database puts up its hand to say that it will take care of the constraints , the front end development and functional testing are easier.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)