I am new Cassandra. please help me to understand how to define best data model in Cassandra.
Model 1:
CREATE TABLE users (
id uuid PRIMARY KEY,
username text,
email text,
age int
)
CREATE TABLE users_by_username (
username text PRIMARY KEY,
id uuid
)
CREATE TABLE users_by_email (
email text PRIMARY KEY,
id uuid
)
Advantages
:
1.No duplicate records.
2. Update/Delete only once , But to find user details need one select
query.
Dis Advantages
1. To get user records, Need to select in 2 tables ( users_by_username
or users_by_email and users )
Model 2:
CREATE TABLE users_by_username (
id uuid PRIMARY KEY,
username text,
email text,
age int
)
CREATE TABLE users_by_email (
id uuid PRIMARY KEY,
username text,
email text,
age int
)
Advantages:
1. To get user records, only once select query.
Dis Advantages:
1.Duplicate records in two tables.
2. Update/Delete needs to performed in two tables.
Please suggest me which model will be good ?