Data Validation at the Database Level

Data Validation at the Database Level

It is tempting to rely on your application to check data before it is saved, but applications change, have bugs and are not the only thing that ever writes to a database. Adding validation rules in the database itself is a last line of defence that keeps your data clean.

This article explains the kinds of rule we apply and why belt-and-braces is worthwhile.

Rules the Database Can Enforce

  • Not null: a required field cannot be left empty.
  • Unique: no two customers share an email.
  • Check: a quantity must be zero or more.
  • Foreign key: a link must point to a real record.

Why Not Just Trust the App

Data often arrives from more than one place — a web app, an admin tool, an import script. A rule in the database applies to all of them, so a bug in one cannot quietly corrupt your data.

Two Layers, One Goal

We still validate in the application for friendly error messages and a good user experience. The database rules sit beneath that, guaranteeing the data is sound no matter what.

If you need a hand with any of this, your Progressive Robot delivery team is ready to help. Raise a ticket from the Support area of your client portal or speak to your account manager and we will guide you through the next steps.

Did you find this article useful?