Database design 如何在cassandra中与表本身建立多对多关系
实际上,我正在开发一个应用程序,在这个应用程序中,一个用户表可以与其自身有多对多的关系 这是一个应用程序,其中一个特定的用户可以向不同的买家出售物品,也可以从不同的卖家购买物品。 也就是说,一个特定的用户可以有很多买家和卖家 因为一个用户正在向其他用户出售物品。 用户成为该特定用户的卖方&该特定用户成为该用户的买方 我对卡桑德拉很陌生,我不知道卡桑德拉的人际关系如何运作 谁能告诉我,我该怎么建立这种关系 我的用户表如下:-Database design 如何在cassandra中与表本身建立多对多关系,database-design,cassandra,data-modeling,database,nosql,Database Design,Cassandra,Data Modeling,Database,Nosql,实际上,我正在开发一个应用程序,在这个应用程序中,一个用户表可以与其自身有多对多的关系 这是一个应用程序,其中一个特定的用户可以向不同的买家出售物品,也可以从不同的卖家购买物品。 也就是说,一个特定的用户可以有很多买家和卖家 因为一个用户正在向其他用户出售物品。 用户成为该特定用户的卖方&该特定用户成为该用户的买方 我对卡桑德拉很陌生,我不知道卡桑德拉的人际关系如何运作 谁能告诉我,我该怎么建立这种关系 我的用户表如下:- CREATE TABLE IF NOT EXISTS user (
CREATE TABLE IF NOT EXISTS user (
id text,
login text,
password text,
firstName text,
lastName text,
gender text,
mobileNo text,
aadhar text,
email text,
stateCode text,
district text,
city text,
zipCode int,
address text,
PRIMARY KEY(id)
);
Cassandra是一个NoSQL数据库,它的一个特殊特性是存储非结构化数据。所以,您不应该考虑表之间的关系,而应该考虑如何获取这些信息(换句话说,您的“select*from”字段是什么) 你应该去看看 之后,您将注意到两件事:
create table sells_by_user_id (
user_id text,
buyer_id text,
date timestamp,
item text,
item_description,
..., <this will depend on which info you would like to obtain
primary key ((user_id), date)); //with this table you will obtain all the things that a user sold and to whom
create table buys_by_user_id (
user_id text,
seller_id text,
date timestamp,
item text,
item_description,
..., <this will depend on which info you would like to obtain
primary key ((user_id), date)); //this table will store all things that an user bought
按用户id创建表(
用户id文本,
买方id文本,
日期时间戳,
项目案文,
项目描述,
…,列出您要执行的所有查询类型。在Cassandra中,表是基于select query设计的。我将处理它,并尝试查看它是否适合我的应用程序