DEV Community

Discussion on: The use cases and benefits of a RDBMS

Collapse
 
shalvah profile image
Shalvah • Edited

This sql script will enforce that, when you want to insert new user into your database, it must not contain duplicate email. No need in your code to enforce this.

It's advisable to do this in your code as well, so you can tell the user "This email has already been used". Otherwise, a database exception will be thrown with a message like "Integrity constraint violation", which you can't show to your users and you can't act on.

Collapse
 
revskill10 profile image
Truong Hoang Dung

Ah, i see your point. In my case, i would just catch the piece of code and handle it like you said and return nice error message to the call site.