What is the canonical way to model many-to-many relations with CQL3 ? Let's say I have to tables
CREATE TABLE actor (
id text PRIMARY KEY,
given text,
surname text,
)
CREATE TABLE fan (
id text PRIMARY KEY,
given text,
surname text,
)
and I'd like to model the fact that an actor can have many fan and each fan can like many actors.
The first idea that came to my my was to use sets, like in the following (and the other way around for fans):
CREATE TABLE actor (
id text PRIMARY KEY,
given text,
surname text,
fans set<text>
)
<similarly for fan>
but it seems they are meant for small sets, and I don't see a way to check if a fan is related to an actor without loading either set completely.
The second choice I found would be to make two mapping tables, each for each relation direction:
CREATE TABLE actor_fan (
text actor,
text fan,
PRIMARY KEY(actor,fan)
);
<similarly for fan_actor>
Would this give me the ability to get both the fan list of an actor and check if a specific person is a fan of a given actor ? There is a lot of documentation about Cassandra, but it is often related to older versions and there seem to be lot of differences between the releases.