Database Reference
In-Depth Information
Storing all the objects for a user
We have already discussed the user table concept in Chapter 3 , Using HBase Tables
for Single Entities . Let's review this, because we are going to build upon it.
You are building a website for video upload and viewing. The first thing that you
would like to do is store information about your users. What would you want to
know about your users? This time, please close the topic and try to design your table,
unlike in Chapter 3 , Using HBase Tables for Single Entities . Here is what you would
want to store:
• Username
• First name, last name, and any other personal information you want
• Password (encrypted in real life)
• One or more e-mails
• Other usability items
This is how a reasonable answer will look:
CREATE TABLE users (
username varchar,
firstname varchar,
lastname varchar,
email list<varchar>,
password varchar,
created_date timestamp,
PRIMARY KEY (username)
);
Note that, as shown in Chapter 3 , Using HBase Tables for Single Entities , you don't need
to generate an ID, because the username is a good identifier and it is unique. That's
nice! No more sequence generators for you; you don't need them. As far as making
usernames unique is concerned, we have already discussed this in Chapter 3 , Using
HBase Tables for Single Entities .
Reminder
Natural keys are better than generated ones.
 
Search WWH ::




Custom Search