I am new to cassandra and need help in data modelling the below scenario. In oracle i have two tables similar to below, which i am thinking of migrating to cassandra.
Usecases to solve: 1. Heavy reads and writes. 2. User data is create first, and we can keep adding or removing accounts to it. 3. Also will be having partial updates to one of the user account like updating the amount or some details of account. 4. User_data has a field to store the count of active user_accounts present. So whenever we add or delete an entry/row in user_account table. it will trigger an update in user_data.
Basically i am not clear how to model these scenarios. Whether to have one single table. But with this, i am not sure of number of the accounts If i have single table and have user_accounts as one of the column with type json. Then, i believe i can't do partial update with in that json.
Main problem in thinking of two table is transaction management. If i was able to add to user_account, but unable to update the user_data then it will be a failure.
create table USER_DATA ( userId uuid PRIMARY KEY, name varchar, noOfAccounts int,
..... #Some more columns ...,
);
create table USER_ACCOUNTS (
userId uuid
accountId uuid ,
amt int,
..... #Some more columns ...,
PRIMARY KEY (uuid,accountId) );
I tried using list of FROZEN USER_ACCOUNTS, but with this we need to read entire list and write back during every addition/deletion or updation to one of its entry.
I tried using json type, but of no use.