understand the data model of Cassandra

// this note is helpful to understand the data model of Cassandra

// ref: http://arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model

 

set up a simple blog system, the requirements are as follow:

1, has many users

2, a blog has the title, body, timestamp

3, any user can comment a blog. a comment has the content, user, and timestamp

4, each blog can have many tags with no count limits

 

schma of Sql/RDMS

table : authors {

id primary_key,

name,

sex,

mail

}

table: blogs {

id primary_key,

title,

body,

timestamp,

author_id foreign_key(authors.id)

}

table: comments {

id primary_key,

content,

timestamp,

author_id foreign_key(authors.id)

}

table: tags {

id primary_key

name

}

table: blog_tags {

blog_id,

tag_id

} // it's the relation !

sample query

select b.title from blogs b, tags t, blog_tags bt

where b.id = bt.blog_id and bt.tag_id = t.id and t.name = 'sql';

 

schma of Cassandra

actually, it's not suitable to use 'schma' here

authors: {

Tom: {

sex: male,

mail: tom@xxx.com

}

}

blogs: {

notes_for_nosql: {

body: blahblahblah,

timestamp: 123456

tags: nosql, dev

}

comments: {

notes_for_nosql: {

timeuuid_1: {

commenter: Lily,

content: good

pubdate: 12345

}

timeuuid_2: {

commenter: John,

content: good job,

pubdata: 123457

}

}

}

 

taggedposts: {

nosql: {

timeuuid_1: notes_for_nosql,

timeuuid_2: learn_cassandra

}

dev: {

timeuuid_3: notes_for_nosql

}

}

to be continued ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值