0

Still learning, but there is something I can't understand.
Some features of MySQL seem (to me) to flow on the responsibilities of the backend.

In particular, I'm talking about data validation (excluding relations) for example NULL/UNIQUE.

Now, I'd like to know why this duplicate? Is it a second layer? More in general, in a good application, do I have to count on the errors raised by the DB as an organic part of the application, or should the application be designed to avoid those errors and only count on them as an extrema ratio?

1
  • 1
    I always thought of a database as being part of a backend. Database integrity is a protection against programming errors, since only rarely an end user gets to access the database directly. If you want your application to be "user friendly", you may need to duplicate a lot of the data validation into the application, not to confront the end user with "database errors". Commented Mar 13, 2021 at 15:30

1 Answer 1

1

An RDBMS is part of the backend, only in rare cases such as access, you can have both.

Even so the GUI should always (try to) prevent errors in the database, and should control the input of its validity.

Errors happen, should not directly shown to the user. But as you have to debug it, you should show helpful ids or text, that could help fixing things.

For a qualified system you have to go a step further and tell the user how he can fix the problem, for example be editing his input in a correct way.

Check constraints help to debug your code, especially in the beginning, when the GUI is only starting, so no problem will be missed.

Foriegn keys, triggers and events help the database maintaining or do things that the user has no influence over, since the RDBMS is a background process (nearly always running on a different machine to the end-user's), that shouldn't come to light.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.