So i am implementing a system that has PIN (Personal identification number) codes. The PIN is a simple combination of a few letters and some numbers. The PIN could be something like
Now, a entity in my database can have many PIN codes, and they must all be unique, but ONLY to that entity ID.
So two different entities can have the same PIN code.
How should i implement this? Should i implement this on the application level, or is it possible to do in the database with some constraints?
Im using Postgres 9.5