あなたの目標がユーザーのすべての注文を取得することである場合、最初のアプローチを使用するのが理にかなっています。
テーブルの作成:
create table orders(
userid int,
orderid int,
insDate timeuuid,
primary key(userid,orderid)
);
挿入:
insert into orders(userid, orderid, insDate) VALUES(1, 1, now());
insert into orders(userid, orderid, insDate) VALUES(1, 2, now());
insert into orders(userid, orderid, insDate) VALUES(2, 3, now());
insert into orders(userid, orderid, insDate) VALUES(3, 4, now());
クエリ:
>select userid,dateof(insdate),orderid from orders where userid in(1,2);
userid | dateof(insdate) | orderid
--------+--------------------------+---------
1 | 2013-11-06 17:26:56+0000 | 1
1 | 2013-11-06 17:26:59+0000 | 2
2 | 2013-11-06 17:27:02+0000 | 3
(3 rows)
(でテスト済み[cqlsh 4.0.1 | Cassandra 2.0.1 | CQL spec 3.1.1 | Thrift protocol 19.37.0]
。)