How to set "data validation" rules on the database?

Let’s say I want to make a certain attribute in a table unique for each row. Where can I set up rules that enforce rules, so that duplicates will be rejected in the DB layer?

Thanks!

You can do a check before save and throw error as explained in the docs