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 ...
// 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,
}
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 ...
相关文章推荐
- Why does Quora use MySQL as the data store instead of NoSQLs such as Cassandra, MongoDB, or CouchDB?
- [Java][DB][Cassandra] some useful link to understand the concepts of SSTable
- Inside The C++ Object Model ---- The Semantics of Data
- Inside The C++ Object Model ---- The Semantics of Data
- The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[BMS.DataAccess.Models.ServiceTyp
- Why does Quora use MySQL as the data store instead of NoSQLs such as Cassandra, MongoDB, CouchDB etc?
- inside the C++ object model chapter 3 the semantics of data
- How to generate the complex data regularly to Ministry of Transport of P.R.C by DB Query Analyzer
- The seven layer of the osi model
- Platform Builder: Find the Source of a Data Abort; an Example
- The Difference Between Big Data and a Lot of Data
- Type of the default value for 'data' prop must be a function
- A simple Example of data processing from Excel as the datasource
- C# Need to understand some of the technical (C# 需要懂的一些技术)
- Application Model of the Magnetic Separator
- JSF遭遇XML解析错误The content of elements must consist of well-formed character data or markup
- The Semantics of Data
- error: couldn't parse contents of '/Users/.../Info.plist': The data couldn’t be read because...
- System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the obj