Enforce uniqueness across multiple rows
The most frequent issues with these solutions concern concurrency.
For example:


You have group id 'A' with activity 1, and group id 'B' with activity 2.
Ali inserts activity 1 into group 'B' but doesn't commit
Bernie inserts activity 2 into group 'A' but doesn't commit
As far as both Ali and Bernie are concerned, there is no conflict as they cannot see the other individual's change
If your application tries to do a check then commit, you have a race condition where bad data can be recorded between the check and commit
If your application does a commit and then check, you have the possibility of the committed data being left in a bad state if no-one responds to the check.


Depending on how important the check is, and how much concurrency you need to accommodate, the simplest solution is to lock the entire table at the start of the transaction (ie Bernie can't do an insert until Ali does a commit).