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 D1F73C496 for ; Thu, 11 Jul 2013 07:01:27 +0000 (UTC) Received: (qmail 94619 invoked by uid 500); 11 Jul 2013 07:01:25 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 94485 invoked by uid 500); 11 Jul 2013 07:01:24 -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 94476 invoked by uid 99); 11 Jul 2013 07:01:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 07:01:23 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.113.200.5] (HELO homiemail-a59.g.dreamhost.com) (208.113.200.5) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 07:01:17 +0000 Received: from homiemail-a59.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a59.g.dreamhost.com (Postfix) with ESMTP id 431D356406C for ; Thu, 11 Jul 2013 00:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=thelastpickle.com; h= content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; s= thelastpickle.com; bh=MltByOTXs63UGWKoROI51CEmTBM=; b=lsm5QPOzAJ 27pbpcOEwnzwwpKH6+cT0zYHARpnVcAgA/rNxdYwpejbPDq7qbnrnyzCIXGB6yh4 NaIZ8+FNqruAuGEaiN1N3lFGTH0lYYdAqIEtjef7c/aLYPBpjBmErqLgQXu/iIJl YrJ178bO/cvxf7YC7wVILxAiVo9npV9oI= Received: from [172.16.1.7] (unknown [203.86.207.101]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: aaron@thelastpickle.com) by homiemail-a59.g.dreamhost.com (Postfix) with ESMTPSA id E4E1A56405C for ; Thu, 11 Jul 2013 00:00:56 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: data model question : finding out the n most recent changes items From: aaron morton In-Reply-To: Date: Thu, 11 Jul 2013 19:00:55 +1200 Content-Transfer-Encoding: quoted-printable Message-Id: <26B2EA04-2477-4B85-A4A8-76B76B37237C@thelastpickle.com> References: To: user@cassandra.apache.org X-Mailer: Apple Mail (2.1508) X-Virus-Checked: Checked by ClamAV on apache.org What you described this sounds like the most appropriate: CREATE TABLE user_file ( user_id uuid, modified_date timestamp, file_id timeuuid, PRIMARY KEY(user_id, modified_date) ); If you normally need more information about the file then either store = that as additional fields or pack the data using something like JSON or = Protobuf.=20 > my return list may still not accurate because a single directory could = have lot of modification changes. I basically end up pulling out series = of modification timestamp for the same directory. Not sure I understand the problem.=20 Cheers ----------------- Aaron Morton Freelance Cassandra Consultant New Zealand @aaronmorton http://www.thelastpickle.com On 10/07/2013, at 6:51 PM, Jimmy Lin wrote: > I have an application that need to find out the n most recent modified = files for a given user id. I started out few tables but still couldn't = get what i want, I hope someone get point to some right direction... >=20 > See my tables below. >=20 > #1 won't work, because file_id's timeuuid contains creation time, not = the modification time. >=20 > #2 won't work, because i can't order by a non primary key = column(modified_date) > #3,#4 although i can now get a time series of modification time of = each file belongs to a user, my return list may still not accurate = because a single directory could have lot of modification changes. I = basically end up pulling out series of modification timestamp for the = same directory. >=20 > Any suggestion? >=20 > Thanks >=20 >=20 >=20 > #1 >=20 > CREATE TABLE user_file ( >=20 > user_id uuid, >=20 > file_id timeuuid, >=20 > PRIMARY KEY(user_id, file_id) >=20 > ); >=20 >=20 >=20 > #2 >=20 > CREATE TABLE user_file ( >=20 > user_id uuid, >=20 > file_id timeuuid, >=20 > modified_date timestamp, >=20 > PRIMARY KEY(user_id, file_id) >=20 > ); >=20 >=20 >=20 > #3 >=20 > CREATE TABLE user_file ( >=20 > user_id uuid, >=20 > file_id timeuuid, >=20 > modified_date timestamp, >=20 > PRIMARY KEY(user_id, file_id, modified_date) >=20 > ); >=20 >=20 >=20 > #4 >=20 > CREATE TABLE user_file ( >=20 > user_id uuid, >=20 > modified_date timestamp, >=20 > file_id timeuuid, >=20 > PRIMARY KEY(user_id, modified_date, file_id) >=20 > ); >=20 >=20 >=20 >=20 >=20