【发布时间】:2019-08-07 22:42:52
【问题描述】:
我正在尝试创建一个网站,用户可以在其中撰写文字帖子,其他用户可以评论帖子,甚至其他用户可以回复评论。 Cassandra 新手,请帮助为此创建数据模型。
现有数据模型如下
CREATE TABLE users (
user_id uuid,
first_name text,
last_name text,
email text,
created_date timestamp,
PRIMARY KEY (userid)
);
CREATE TABLE user_credentials (
email text,
password text,
userid uuid,
PRIMARY KEY (email)
);
CREATE TABLE user_posts (
user_id uuid,
post_id timeuuid,
content text,
PRIMARY KEY (user_id, post_id) )
WITH CLUSTERING ORDER BY (post_id DESC);
Create TABLE comment_by_post (
post_id timeuuid,
user_id uuid,
comment_date timestamp,
context text ,
primary key (post_id,user_id,comment_date))
WITH CLUSTERING ORDER BY (comment_date);
Create Table comment_by_user (
post_id timeuuid ,
user_id uuid,
comment_date timestamp ,
content text,
primary key (user_id,post_id,comment_date))
WITH CLUSTERING ORDER BY (comment_date);
【问题讨论】:
-
我认为这不是 cassandra 建模或 mysql 等的问题。首先您必须考虑您的应用程序中的用户是什么,您的应用程序中的帖子或评论是什么?
-
它是一个简单的应用程序,用户可以在其中写帖子“文本”,其他用户可以评论帖子。@Novy
-
您实际上并不需要用户凭据表,此信息可以存储在用户中。然后使用 spring 数据,您可以使用投影来仅显示用户存储库的某些部分。你的数据模型有什么问题? @shubham bhindwal
-
我在创建评论系统时遇到问题,用户可以通过帖子@Novy 回复其他 cmets
标签: java database spring-boot cassandra