I have a table of event_id, role_id, and rank. The following table should help visualize the various outcomes we expect with regards to our constraints:
scenario Event_Id Role_Id Rank
1 1 1 1 good
2 1 2 1 bad
3 2 1 1 good
Event_Id is the primary key of the Event table.
Role_Id is the primary key of the Role table.
Using Event and Role we find the rank associated to that role for that given event.
A role can be used in multiple events with different ranks (scenarios 1 and 3)
However, a 2 roles should not have the same rank for the same event. (scenarios 1 and 2)
How can we establish these constraints so that we can identify a rank for a given role in a given event, but the rank of a role is only unique within that event?