您的位置:首页 > 其它

understand the data model of Cassandra

2011-10-06 02:15 246 查看
// 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 ...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: