Database – Preventing errors from input

Is it a good practice to fully delegate data validation to database engine constraints?

Validating data from an application does not prevent invalid insertion from another software (maybe written in another language by another team). Using database constraints can reduce the need to worry about invalid input data .

If you verify in both the database and the application, then maintenance becomes boring because you have to update the code of who knows how many applications there are, which increases the possibility of human error.

I just can’t see doing this, looking at the code of the free software project.

Where possible, it’s best to specify validation rules in the database, and use or write a framework to make these rules bubble up to your front end. ASP.NET dynamic data helps achieve this, and there are some Commercial libraries can make it easier.

This can be used for simple input validation (such as numbers or dates), or for related data subject to foreign keys.

In short, our idea is to define rules in one place (most of the time in the database), and use code in other layers to enforce these rules.

Is it a good practice to entrust data validation to the database engine constraints?

Validating data from an application does not prevent invalid insertion from another software (maybe written in another language by another team). Using database constraints can reduce the need to worry about invalid input data .

If you verify in both the database and the application, then maintenance becomes boring because you have to update the code of who knows how many applications there are, which increases the possibility of human error.

I just can’t see doing this, looking at the code of a free software project.

When possible, it’s better to Specify validation rules in the database, and use or write a framework to make these rules bubble up to your front end. ASP.NET dynamic data helps to achieve this, and there are some commercial libraries that can make it easier.

< /p>

This can be used for simple input validation (such as numbers or dates), and it can also be used for related data constrained by foreign keys.

In short, our idea is in one place (Most of the time in the database) define rules and use code in other layers to enforce these rules.

Leave a Comment

Your email address will not be published.