Take, for example, an application in which there are users, each of which can be in the same group. If we want to CHOOSE a list of groups that have no members, what will be the correct SQL? I always feel that I am going to understand this question, and then disappears again.
Bonus points - given the alternative senario, where it is a lot, a lot of pairing, what is SQL to identify unused groups?
(if you need specific field names :) One-to-many:
Table 'users': | user_id | group_id |
Table 'groups': | group_id |
Many-to-many:
Table 'users': | user_id |
Table 'groups': | group_id |
Table 'user-group': | user_id | group_id |
source
share