Let’s talk about the conclusion first: I agree with LS’s point of view. Generally, verification is written in the program, and the database only does basic constraints such as unique
If you really want to do it in the database, you will usually write trigger
Then there seems to be add constraint check, but even if mysql supports this, it will not check before storage (all engines)
This kind of basic verification is also done in the database. Doesn’t this just put more pressure on the database? Everyone is reducing the burden on it
Achieved through stored procedures or triggers, but this logic is best controlled by the code layer
Let’s talk about the conclusion first: I agree with LS’s point of view. Generally, verification is written in the program, and the database only does basic constraints such as unique
If you really want to do it in the database, you will usually write trigger
Then there seems to be add constraint check, but even if mysql supports this, it will not check before storage (all engines)
http://stackoverflow.com/questions/16005283/is-it-possible-to-enforce-data-checking-in-mysql-using-regular-expression
Program logic problems should not be left to the database to handle, or it should be used as the last line of verification defense.
Check before or during submission.
This kind of basic verification is also done in the database. Doesn’t this just put more pressure on the database? Everyone is reducing the burden on it