I need to model account (first name, last name, email as username etc.) in cassandra along with currently active token.
My initial idea was to create account_by_email
which will have skinny row partitioned by email with static columns and have clustering by access_token
(and maybe TTL) and than you can always find access token based on current email.
But we have requirement that clients will send after login only access_token
and based on it current user must be pulled from DB.
I can create one more table where email will be partitioned by access_token
but that seams to me as overhead and lot of partitions. Then I could get email from access_token
and get user by email always.
Any better ideas and approaches, it seams that this is common use case but I cannot find any modeling details when cassandra is used as storage?
I can create one more table where email will be partitioned by access_token but that seams to me as overhead and lot of partitions.
What's wrong with a large number of partitions it a table? It's definitely a correct Cassandra-way of doing things:
create table users (
email text primary key,
first_name text,
last_name text,
current_token text
);
create table tokens (
auth_token text primary key,
valid_until timestamp,
email text
);
So you have a separate tables for users, and the tokens
table which has token as a partition key. With this model you can:
tokens
table.current_token
column.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With