Suppose I have two tables: thread
and user
, with a join table thread_user
that models a many-to-many relationship between them.
Suppose I want to enforce the following constraints:
- A
thread
can have at most 10user
s. - No two
thread
s should have the same set ofuser
s.
How can this be done? The first constraint seems easy enough to enforce with a trigger (is there a better approach?). The second constraint I have no idea how to enforce.