- Rule 1. I do not trust the backend.
- Rule 2. I do not trust the frontend.
- Rule 3. I and only I decide what should I store or not.
When managing a database you want to remember the three rules
above. As we do not know which silly magic is used to fill the data
in our database we need to ensure
the integrity
of our data. defining a data type
(text, integer, date) is not secure
enough. So most
database manager (MySql, SQLite, MariaDB) use CHECK
Constraints. It is a simple process
to verify
that the inputs
fits the requirements of your app before inserting
any data in your tables.
Important:
CHECK(...)
behave likeif
constraints which means you canperfom
anyoperations
within the parenthesis.