I have a table. Lets say we have a userid of 23, which corresponds to various roles that the user might hold: scientist, researcher and developer. ID's respectively: 2,8,9.
So, userid can be duplicated but roleid as it relates to userid is unique. Note that if there are more then 1 users I want it so that roles can be duplicated (unique to the user, duplicated across different users) such as:
In Yii, under rules of the model you can create a rule to do uniqueness. I want the RoleID field to be unique for that user. So if user x has role y, it won't add role y again (creating duplicates).
here's the schema: