Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3A0F18FCF for ; Mon, 11 Apr 2016 06:00:24 +0000 (UTC) Received: (qmail 94992 invoked by uid 500); 11 Apr 2016 06:00:22 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 94949 invoked by uid 500); 11 Apr 2016 06:00:22 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 94939 invoked by uid 99); 11 Apr 2016 06:00:21 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2016 06:00:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 79D1F180220 for ; Mon, 11 Apr 2016 06:00:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id o6Md9eDJ5Ela for ; Mon, 11 Apr 2016 06:00:19 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id E213D5FB27 for ; Mon, 11 Apr 2016 06:00:18 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id j11so141694200lfb.1 for ; Sun, 10 Apr 2016 23:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=a3FXTkko5Mr6xAar/M7BZHTgzK6SjfTftbPc+ISipFk=; b=0fFvcniN6T/ZHWb5tIZPnAMdxfabDlJ6JPCj8ZGZs3B5oae1yDP3vH9YOSnul7ZT0P Hw/ujAoRJCksSIMPtsiH1UY/a+U94gIdzFR2XX0cuDZt10qri7W//F5EADVa3+A5yO0D 4eOdCfov3dxOvzy0AxSQ5CN/CsCZ+Fb7yJN94htLFNlS24cUgkIFHZaHoCGCnT1kQJ2D 6+a+Xk0QRFGUsV/zTNfIcmi/D9qNG+bWRJiy0BGkEG719lIcfvBw32BLlUMdwMLrEtKR myMC7UZDClnMxGDTntBYcX0/dbN5gJxWIuuzRnwMfvbD6gZCbC/AFlzYLR/HHwDXT/EN +rxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=a3FXTkko5Mr6xAar/M7BZHTgzK6SjfTftbPc+ISipFk=; b=DyD0Pt0aqBwOgP+qowFcJY3FJprQ9k2IdzvtlAXoSCpLt4t2b7KHnyhlEMqcGuEKQT bj35+GDoPBKMO+1Tw2j9x3R9QZ7Kb9VaMrp663Sjo5+fzYmLb0LlqQFp3diVi31r2hGe mIC5wtoC0XlB+4OHWwnS6xkhLTCXFqoIfJuK9D2rO01+sZvj59N4iPDT0kRajcUx3JPy ZG+LwkBPiVC2MVarABENXgaqTC6qD+aK/75hAODStn9Vm+yB3UXhfhJ9CjZY7a8hcyiI WU8kDdxjhuCxJgOPOl6txpCpkEfIKVa0UxKi6IfyL9j8NZGhzriYdr+F+pWGlz9OaKTL ceUA== X-Gm-Message-State: AD7BkJLBvyqz0YBMyACV+ynURiANDd6YbsATYTYUAPXQK8UibN61NSEwyELmYxO5M8W2UmIoAn/HhJoj3NLZng== X-Received: by 10.112.51.8 with SMTP id g8mr5917980lbo.109.1460354417393; Sun, 10 Apr 2016 23:00:17 -0700 (PDT) MIME-Version: 1.0 References: <34166F13-68CB-4768-A2D1-EEA17528AE34@gmail.com> In-Reply-To: <34166F13-68CB-4768-A2D1-EEA17528AE34@gmail.com> From: Bo Finnerup Madsen Date: Mon, 11 Apr 2016 06:00:07 +0000 Message-ID: Subject: Re: Data modelling, including cleanup To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=001a11333e4c4b850d05302f4277 --001a11333e4c4b850d05302f4277 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=B6ger : > Hi, > > That=E2=80=99s how I have done it in many occasions. Nowadays there is th= e > possibility use Cassandra 3.0 and materialised views so that you don=E2= =80=99t 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 > 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 > > > --001a11333e4c4b850d05302f4277 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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. m= ar. 2016 kl. 11.16 skrev Hannu Kr=C3=B6ger <hkroger@gmail.com>:
Hi,

That=E2=80=99s = how I have done it in many occasions. Nowadays there is the possibility use= Cassandra 3.0 and materialised views so that you don=E2=80=99t need to kee= p two tables up to date manually:

Hannu

On 17 Mar 2016, at 12:05, Bo = Finnerup Madsen <bo.gundersen@gmail.com> wrote:

<= div>Hi,

We are pretty new to data modelling in cas= sandra, and are having a bit of a challenge creating a model that caters bo= th for queries and updates.

Let me try to explain = it using the users example from http://www.datas= tax.com/dev/blog/basic-rules-of-cassandra-data-modeling

<= /div>
They define two tables used for reading users, one by username an= d one by email.
-------------------------------------------------= --------------------
CREATE TABLE users_by_username (
= =C2=A0 =C2=A0 username text PRIMARY KEY,
=C2=A0 =C2=A0 email text= ,
=C2=A0 =C2=A0 age int
)
=C2=A0
CR= EATE TABLE users_by_email (
=C2=A0 =C2=A0 email text PRIMARY KEY,=
=C2=A0 =C2=A0 username text,
=C2=A0 =C2=A0 age int
)
--------------------------------------------------------= -------------

Now lets pretend that we need to del= ete a user, and we are given a username as a key. Would the correct procedu= re be:
1) Read the email from users_by_username using the usernam= e 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,
=C2=A0 Bo Madsen


--001a11333e4c4b850d05302f4277--