I have a table named GroupMembers, which represents a list of users participating in certain communities on a website.
Columns look something like this:
groupId | accountId | role
Such a constraint exists . . . but not in MySQL. Other database allow you to implement filtered indexes or indexes on computed columns.
Instead, you can implement this logic in the
Groups table by having the creator:
alter table groups add column creatorUserId int; alter table groups add constraint fk_groups_creatorUserId foreign key creatorUserId references users(creatorUserId);