【发布时间】:2016-05-16 22:49:14
【问题描述】:
这是对这个问题的扩展:
How to increment Cassandra Counter Column with phantom-dsl?
here 也有人问过这个问题。
在Thiagos example这两个表中; 'songs' 和 'songs_by_artist' 都具有相同的行但具有不同的分区(主键/集群列)
CREATE TABLE test.songs (
song_id timeuuid PRIMARY KEY,
album text,
artist text,
title text
);
CREATE TABLE test.songs_by_artist (
artist text,
song_id timeuuid,
album text,
title text,
PRIMARY KEY (artist, song_id)
) WITH CLUSTERING ORDER BY (song_id ASC);
这意味着在 SongsService 内的两个表中插入、更新和删除都适用于相同的基本数据/行。
例如,您将如何拥有一个表,例如“artist_songs_counts”,其中包含“song_id”(K)和“num_songs”(++)列,并确保“SongsService”为每个表添加相应的行; 'songs' & 'songs_by_artist' & 'artist_songs_counts'(行数不同,但信息应关联,例如艺术家信息)。
CREATE TABLE test.artist_songs_counts (
artist text PRIMARY KEY,
num_songs counter);
【问题讨论】:
-
@flavian 这可能是你的另一个...
标签: scala cassandra-2.0 phantom-dsl