You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Bo Finnerup Madsen <bo...@gmail.com> on 2016/04/11 08:00:07 UTC

Re: Data modelling, including cleanup

Hi Hannu,

Thank you for the pointer. We ended up using materialized views in
cassandra 3.0.3. Seems to do the trick :)


tor. 17. mar. 2016 kl. 11.16 skrev Hannu Kröger <hk...@gmail.com>:

> Hi,
>
> That’s how I have done it in many occasions. Nowadays there is the
> possibility use Cassandra 3.0 and materialised views so that you don’t need
> to keep two tables up to date manually:
> http://www.datastax.com/dev/blog/new-in-cassandra-3-0-materialized-views
>
> Hannu
>
> On 17 Mar 2016, at 12:05, Bo Finnerup Madsen <bo...@gmail.com>
> wrote:
>
> Hi,
>
> We are pretty new to data modelling in cassandra, and are having a bit of
> a challenge creating a model that caters both for queries and updates.
>
> Let me try to explain it using the users example from
> http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling
>
> They define two tables used for reading users, one by username and one by
> email.
> ---------------------------------------------------------------------
> CREATE TABLE users_by_username (
>     username text PRIMARY KEY,
>     email text,
>     age int
> )
>
> CREATE TABLE users_by_email (
>     email text PRIMARY KEY,
>     username text,
>     age int
> )
> ---------------------------------------------------------------------
>
> Now lets pretend that we need to delete a user, and we are given a
> username as a key. Would the correct procedure be:
> 1) Read the email from users_by_username using the username as a key
> 2) Delete from users_by_username using the username as a key
> 3) Delete from users_by_email using the email as a key
>
> Or is there a smarter way of doing this?
>
> Yours sincerely,
>   Bo Madsen
>
>
>