Keep in both.
The thing I see most nowadays are systems where the rules are only in the application, since currently knowing the minimum database seems to be a great requirement.
What happens? In the best case scenario, where only your application uses the database: some user goes there directly in the DBMS and erases some data. As there is no foreign_keys, ready: now the data is inconsistent. And I see this with a frightening frequency.
Worst-case scenario, multiple apps will have access to the same bank.
So, at the very least, also keep in the bank the fields that are mandatory (defined as NOT NULL
), foreign keys, and use restrictions for values such as ENUM in Mysql (or Oracle CHECK) when possible.
Validation (at least mandatory fields) and constraints (like foreign_keys) on the seat are like a seat belt: you’ll think you never need them until an accident happens.
Speaking exclusively of field obligation I do not see why a NOT NULL is a subject of discussion.
– Motta
NOT NULL
It’s nothing to argue about. if the field is mandatory, it must be present, if it is not mandatory, the field should not even be in the same table but in another auxiliary table.– Bruno Coimbra