How to save 2 Cassandra tables inside one partition

I tried reading blogs and datastax documentation but couldn't find any specific ones on this

Is there a way to save 2 tables in Kassandra so that they belong to the same partition? For instance:

CREATE TYPE addr ( street_address1 text, city text, state text, country text, zip_code text, ); CREATE TABLE foo ( account_id timeuuid, data text, site_id int, PRIMARY KEY (account_id) }; CREATE TABLE bar ( account_id timeuuid, address_id int, address frozen<addr>, PRIMARY KEY (account_id, address_id) ); 

Here I need to make sure that both of these / CF tables will live on the same partition this way for the same account. Both of these datasets can be extracted from the same node.

Any pointers are highly appreciated.

Also, if anyone has experience using UDT (User Defined Types), I would like to understand how backward compatibility will work. If I modify the UDT "addr" to have a few more attributes (for example, zip_code2 int and name text), how do the older lines that have this attribute work? Is it even compatible?

thanks

+5
source share
1 answer

If two tables use the same replication strategy and the same partition key, they will place their partitions. As long as two tables are in the same keyspace, and their partition keys correspond

PRIMARY KEY (account_id) == PRIMARY KEY (account_id, address_id)

Any given account_id will be enabled (and replicated) on the same machines.

+10
source

Source: https://habr.com/ru/post/1238300/


All Articles