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 B881010257 for ; Thu, 12 Dec 2013 02:38:10 +0000 (UTC) Received: (qmail 6415 invoked by uid 500); 12 Dec 2013 02:38:07 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 6220 invoked by uid 500); 12 Dec 2013 02:38:07 -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 6104 invoked by uid 99); 12 Dec 2013 02:38:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Dec 2013 02:38:07 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.192.171] (HELO mail-pd0-f171.google.com) (209.85.192.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Dec 2013 02:38:01 +0000 Received: by mail-pd0-f171.google.com with SMTP id z10so10619295pdj.16 for ; Wed, 11 Dec 2013 18:37:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-type:message-id:mime-version :subject:date:references:to:in-reply-to; bh=ppIQEytVaK9fBOCt7h0UCrNMNCOdZRqfjmRew35SrgM=; b=YbOy0/rNO4VIbOv+gqT6uMmheOrGejpOsWGcy1CT8waHAmJVgTxmhyv1arbaB0kDC7 eUHhEAYx1pDxf/H516nBJ5KwOt/IJeRXaU4BDUdzo9yK3ePr/MAmQd/ZIrox64rFlfI6 R+p7foo7cMSX0fQMex5ZUypT1WGqMAF5zMAq8YZQxK5/zutif3YQ4BUI6eu5I6fS2/eZ BjLrKoUQRyaM0CQJhibYxz/9b7pq84smw9cRCg8RGOyrq49APhc7LVWl/JYYXPRjmQhv tCVWAhzw48fCV1Hiny0oDz0cfl9OWsQYwqMoti5Kpw1fHkwp31IkT6ZKPHxmgsz9stVN vT6Q== X-Gm-Message-State: ALoCoQnCNo7TO7ORGrXPhnh6IdSHVgg1wkcZmL4dJWfxwnjxxSzNp6CIrqUzumYgvCWtrUlH/SKY X-Received: by 10.68.211.1 with SMTP id my1mr7234771pbc.55.1386815859761; Wed, 11 Dec 2013 18:37:39 -0800 (PST) Received: from [172.16.1.18] ([203.86.207.101]) by mx.google.com with ESMTPSA id oj6sm49918320pab.9.2013.12.11.18.37.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Dec 2013 18:37:38 -0800 (PST) From: Aaron Morton Content-Type: multipart/alternative; boundary="Apple-Mail=_C119449C-67F6-4E37-ABAC-E8EBA0F0459A" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) Subject: Re: Data Modelling Information Date: Thu, 12 Dec 2013 15:37:34 +1300 References: To: Cassandra User In-Reply-To: X-Mailer: Apple Mail (2.1822) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_C119449C-67F6-4E37-ABAC-E8EBA0F0459A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 > create table messages( > body text, > username text, > tags set > PRIMARY keys(username,tags) > ) This statement is syntactically invalid, also you cannot use a = collection type in the primary key.=20 > 1) I should be able to query by username and get all the messages for = a particular username yes.=20 > 2) I should be able to query by tags and username ( likes select * = from messages where username=3D'xya' and tags in ('awesome','phone')) No. > 3) I should be able to query all messages by day and order by desc = and limit to some value No. > Could you guys please let me know if creating a secondary index on the = tags field? No, it=92s not supported.=20 > Or what would be the best way to model this data. You need to describe the problem and how you want to read the data. I = suggest taking a look at the data modelling videos from Patrick here = http://planetcassandra.org/Learn/CassandraCommunityWebinars Cheers ----------------- Aaron Morton New Zealand @aaronmorton Co-Founder & Principal Consultant Apache Cassandra Consulting http://www.thelastpickle.com On 10/12/2013, at 8:57 am, Shrikar archak wrote: > Hi Data Model Experts, > I have a few questions with data modelling for a particular = application. >=20 > example > create table messages( > body text, > username text, > tags set > PRIMARY keys(username,tags) > ) >=20 >=20 > Requirements > 1) I should be able to query by username and get all the messages for = a particular username > 2) I should be able to query by tags and username ( likes select * = from messages where username=3D'xya' and tags in ('awesome','phone')) > 3) I should be able to query all messages by day and order by desc = and limit to some value >=20 >=20 > Could you guys please let me know if creating a secondary index on the = tags field? > Or what would be the best way to model this data. >=20 > Thanks, > Shrikar --Apple-Mail=_C119449C-67F6-4E37-ABAC-E8EBA0F0459A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
create= table messages(
= body text,
username text,
tags = set<text>
= PRIMARY = keys(username,tags)
)

This statement is syntactically invalid, = also you cannot use a collection type in the primary = key. 

1) I should be able to query by username and get all the = messages for a particular username
yes. 

2) I should be = able to query by tags and username ( likes select * from messages where = username=3D'xya' and tags in = ('awesome','phone'))
No.

3) I should be = able to query all messages by day and  order by desc and limit to = some value
No.

Could you guys please let me know if creating a secondary = index on the tags field?

No, it=92s not = supported. 


Or what would be the best way to model this = data.

You need to describe the problem and how you want to read = the data. I suggest taking a look at the data modelling videos from = Patrick here http:= //planetcassandra.org/Learn/CassandraCommunityWebinars

Cheers

http://www.thelastpickle.com

On 10/12/2013, at 8:57 am, Shrikar archak <shrikar84@gmail.com> = wrote:

Hi Data Model Experts,
I = have a few questions with data modelling for a particular = application.

example
create = table messages(
= body text,
username = text,
= tags set<text>
PRIMARY keys(username,tags)
=
)


Requirements
1) I should be able to query by username and get all the messages for = a particular username
2) I should be able to query by tags and = username ( likes select * from messages where username=3D'xya' and tags = in ('awesome','phone'))
3) I should be able to query all messages by day and  order by = desc and limit to some = value


Could you guys please let = me know if creating a secondary index on the tags field?
Or what would be the best way to model this = data.

Thanks,
Shrikar

= --Apple-Mail=_C119449C-67F6-4E37-ABAC-E8EBA0F0459A--