Hello QuyenPN,
You forgot to tell us what typical search queries you will do against
your database.
If you know the user id and mail id, and just want to get the mail
content, then you may even not need super columns:
key= userid_mailid->content:the_content
If you only know the user id and want to get the mails for that user,
you could get the mails ID using and key ordered scanner.
Cheers
TR
Quyen Pham Ngoc wrote:
Hi all,
I know the limitation when using super column.
"# Cassandra has two levels of indexes: key and column. But in super
columnfamilies there is a third level of subcolumns; these are not
indexed, and any request for a subcolumn deserializes _all_ the
subcolumns in that supercolumn. So you want to avoid a data model that
requires large numbers of subcolumns"
I have Mail data model like
//Column Family
MailBox{
userId{//row key
"inbox":{//super column
mailId1: mailData1,
mailId2: mailData2
},
"outbox":{//super column
mailId3: mailData3,
mailId4: mailData4
}
}
}
I know above design violate the Cassandra limitation with super
column, because day by day, email user send and receive increase.
Try to avoid this, I have 2 solution:
1. Use 2 column Family: InboxMailBox and OutboxMailBox
//Column Family
InboxMailBox{
userId{//row key
mailId1: mailData1,
mailId2: mailData2
}
}
//Column Family
OutboxMailBox{
userId{//row key
mailId3: mailData3,
mailId4: mailData4
}
}
2. Use complex row key: I use a prefix append to userId, ex "inbox" or
"outbox"
//Column Family
MailBox{
prefix + userId{//row key
mailId1: mailData1,
mailId2: mailData2
}
}
Could you give me some advice?
Thanks a lot for support.
Best regards,
QuyenPN