Writing a messaging system, we have an entity with a “from” ref and a “to” many-cardinality ref. In classic messaging style, we want to be able to select all the messages between two individuals where no one else is in the loop. So,
Bob (to Ted): Hello
Ted (to Bob): Hello
Bob (to Ted and Carol and Alice): Did you get that thing I sent you?
So, if we’re trying to display conversations between Bob & Ted, we want to be able to say just those two, and not the messages that also pull in Carol and Alice.
I saw this which seems slightly off and a little overkill.
I’m not at the point where I can really get your gist. I would have hoped there were standard ways of dealing with “many” refs. You know, select the entities with references that are exactly this, any combination of that, etc.
Do I pull them all out and run counts on the result set?
What you need is a not-join clause to filter out the messages to other users. Here’s an example (schema, sample data according to your scenario, and a query):
(note: this is a scrollable div below and some of the syntax highlight is wrong):