Reputation: 5728
I was reading/studying about HBase and trying to create a Schema. I'm from RDBMS background and this is the first time trying a nosql db. I've a simple question about schema design:
Assume there are three tables => album, photo, comment
album <= Created by the user
photo <= Contains all photos uploaded to an album
comments <= Contains commenrs on an album or photo
A photo should be fetched with all of comments under it. An album should be fetched with all the photos in it but not comments.
user is identified by the email. The schema that I came up with:
email || info: {password : ..., name : ...}
<email>:album:<timestamp> || info {title:..., cover: photo-row-key}
<album-row-key>:<timestamp> || info {caption:..., exif: ...}
<album-row-key or photo-row-key> || comments {
comment:<timestamp>: {user: <email>, text:...}
comment:<timestamp>: {user: <email>, text:...}
comment:<timestamp>: {user: <email>, text:...}
...
}
<album-row-key or photo-row-key>:comment:<timestamp>
? As per above schema whenever a user creates a comment, I need to read comments column, update it with new comment and update the row with tha. Does it sound fine?It'll be very helpful if you could share some link(s) which has/have examples of schemas that suit more for RDBMS :)
Upvotes: 4
Views: 287
Reputation: 25909
One alternate is to put the comments and the photos and the albums in the same table Also put the photos & photos comments in one column family and the album comments in another column family
Then you can get the data in a single access depending on you needs. eg.:
Upvotes: 3