So I've got some data. There are entities. Entities have an arbitrary number of items. Items can be one of a defined set of types. An entity can have more than one item of a given type. I can get a list of items that an entity has. What I want is to get a list of types that an entity doesn't have an item for.
Here's my schema:
entities
id name
1 Bob
2 Alice
item_types
id name
1 red
2 yellow
3 green
4 blue
5 orange
items
entity_id item_type_id name
1 1 apple
1 2 banana
1 3 lime
1 3 tree
2 3 money
2 5 traffic cone
I would like to query Bob's id (1) and get this list:
4 blue
5 orange
And query Alice's id (2) and get:
1 red
2 yellow
4 blue
It's probably starting me in the face. I'm gonna keep working on it but I bet you SO peeps beat me to it. Thank you kindly for your time.