Modeling many-to-many relations in Cassandra 2 with CQL3

后端 未结 2 1970
我在风中等你
我在风中等你 2021-02-09 12:49

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,
          


        
相关标签:
2条回答
  • 2021-02-09 13:31

    The proper way to do this in Cassandra is denormalizing the data into 2 tables. You shouldn't worry about having to write twice, once on each table, as Cassandra is designed to handle writes very fast to support such model.

    Take a look at this data modelling tutorials that will help understanding these things:

    Data modelling tutorials

    Also I see you mentioned sets as well. Just as a side note and although it is not an answer to your questions, you might want to be aware of some new features like: http://www.datastax.com/dev/blog/cql-in-2-1

    0 讨论(0)
  • 2021-02-09 13:35

    The way to achieve it is denormalizing data creating an actors_by_fans and a fans_by_actors. You can also use sets but this have limitations you already mentioned.

    HTH, Carlo

    0 讨论(0)
提交回复
热议问题