【发布时间】:2016-08-06 01:00:37
【问题描述】:
我有这个架构可以将 post 及其评论一起存储在同一个表中:
CREATE TABLE post (
post_id int,
access_key text,
comment_id int,
title text,
comments FROZEN <type_comment>,
PRIMARY KEY ((post_id, access_key), comment_id)
);
CREATE TYPE ks_test.type_comment (
id int,
content text
);
这是一个示例数据
post_id | access_key | comment_id | comments | title
---------+------------+------------+--------------------------+--------------
1 | about_post | 1 | null | this is post
1 | comments | 2 | {id: 2, content: 'cmn1'} | null
1 | comments | 3 | {id: 3, content: 'cmn2'} | null
1 | comments | 4 | {id: 4, content: 'cmn3'} | null
我正在使用此架构,因此我只需访问一个表即可获得post 及其注释。这种模式的优缺点是什么?
【问题讨论】:
标签: cassandra cql datastax cql3 datastax-java-driver