2012-04-12 30 views
2

正如標題所說,我對NoSQL DBS(如Cassandra)非常瞭解(全部閱讀)。和其他人一樣,我以前學過RMDBS。所以我在'WTF是一個超級專欄'和其他明顯的谷歌點擊做了一些閱讀,但我仍然不知道如何建模這個:Cassandra/NoSQL新手:正確的建模方式?

說我想保存用戶,如在用戶名/密碼/名稱/等等......如果那個用戶有,手機和座機電話怎麼辦?這是「正確」的方式嗎? (使用相同的縮寫JSON風格在其他網站上可以看到)

Users: { // <-- this is the Users SuperColumnFamily, keyed by username 
    myuser: { // <-- this is a User SuperColumn 
     username = "myuser", // <-- this is the username Column 
     email = "[email protected]", 
     ... 
    }, 
    ... 
} 

Phone: { // <-- this is where the users phone numbers are stored 
    myuser: { 
     mobile = "0129386835235", 
     landline = "123876912384", 
    }, 
    ... 
} 

的意見/更正請先

回答

4

第一件事,不要使用超級列。請參閱:

http://www.quora.com/Cassandra-database/Why-is-it-bad-to-use-supercolumns-in-Cassandra

現在回答你的問題。你描述的例子很容易用只是一個普通的列族建模:

Users: { <- This is the name of the column family 
    username1: { <- this is a row key within the column family, it is one of your usernames 
    email: [email protected] <- these are all of the columns within this row, they correspond to attributes for this user 
    mobile: ... 
    landline: ... 
    } 
    username2: { <- another row for a different user 
    email: [email protected] 
    } 
} 

你可以在上面看到在每一行都有用於描述該用戶的不同組列的靈活的模式。

有關Cassandra的數據模型,我會推薦閱讀過http://www.datastax.com/docs/1.0/ddl/index

+0

謝謝你更多的信息,我想太多關係 – 2012-04-13 06:17:28