Database Reference
In-Depth Information
Solution
Insert the user data using the following query:
INSERT INTO users
(username, firstname, lastname, email, password, created_date)
VALUES ('johnsmith', 'John', 'Smith', ['johnsmith@gmail.com',
'johnsmith@yahoo.com'], 'password123', '2013-09-09');
INSERT INTO users
(username, firstname, lastname, email, password, created_date)
VALUES ('johnsmith', 'John', 'Smith', ['johnsmith@gmail.com',
'johnsmith@yahoo.com'], 'password123', '2013-09-09');
Now, prepend an e-mail like this:
UPDATE users SET email = ['me@johnsmith.com'] + email WHERE username
= 'johnsmith';
Then, you can append the e-mail at the end as follows:
UPDATE users SET email = email + ['me@johnsmith.com'] WHERE username
= 'johnsmith';
Analyze your queries using the explain command (for more details, go to http://
phoenix.incubator.apache.org/language/index.html#/explain . )
What does the explain command do? It computes the logical steps necessary to
execute the given command. This is similar to the execution plan you will find in SQL
databases. Each step is then represented as a string in a single-column result set row.
Summary
In this chapter, we learned how to design tables for simple single entities. The key
notions here were how and when to generate HBase rows' keys, why sequence key
generation is an antipattern, how to use the lists of values in your schema, and how
to make Phoenix's SQL array do the work for you.
In the next chapter, we will look at the principles of storing time series data, how
to avoid the pitfalls characteristic of this type of problem, and how to use best
practices that can help guarantee performance and scalability of HBase.
 
Search WWH ::




Custom Search