HBase: Regarding the circuit

I read / studied HBase and tried to create a circuit. I am from the RDBMS database and this is the first time you are trying to run nosql db. I have a simple question about circuit design:

Suppose there are three tables => album, photo, comment

  • album <= Created by
  • photo <= Contains all the photos uploaded to the album
  • comments <= Contains commenrs on an album or photo

    The photo should be taken taking into account all comments. The album must be uploaded with all the photos in it, but not with comments.

user is identified by email. The scheme I came across:

tbl_user

email || info: {password : ..., name : ...} 

album

 <email>:album:<timestamp> || info {title:..., cover: photo-row-key} 

Photo

 <album-row-key>:<timestamp> || info {caption:..., exif: ...} 

A comment

 <album-row-key or photo-row-key> || comments { comment:<timestamp>: {user: <email>, text:...} comment:<timestamp>: {user: <email>, text:...} comment:<timestamp>: {user: <email>, text:...} ... } 
  • Does this design all right? I just want to know the changes that should / should be made and why.
  • If the photo-line key is not added by the line-album keys (possibly to save space)?
  • Regarding the comment table, should I create a comment string key as <album-row-key or photo-row-key>:comment:<timestamp> ? According to the above diagram, whenever a user creates a comment, I need to read the comment column, update it with a new comment and update the line with tha. Does this sound normal?

It will be very useful if you could share some links (links) that have / have examples of schemes that are more suitable for a DBMS :)

+4
source share
1 answer

One option is to post comments and photos and albums in one table. Also add comments to photos and photos in one column family, and album comments in another column family.

  • The album line has an email address: album: 0: 0: the line with the date stamp has a key
  • email: album: photo: 0: timestamp photo comment row key
  • email: album: photo: comment: timestamp album comment row key
  • Email: Album: Comment: Timestamp

Then you can get data in one access, depending on your needs. eg:.

  • One scan using the prefix gives you an album with all the photos and all their comments
  • One scan using the prefix and the last key will give you an album with its photos, but not comments
  • One email scan: an album for the second column family will give you an album with all its comments
  • One email scan: album: photo prefix will give you a photo with all its comments
  • one email scan: an album with all column families will give you all the data
  • email scanning with endkey by album.max: provides you with all the albums for the user
  • and etc.
+3
source

All Articles