Database Reference
In-Depth Information
Working with static columns
Let's say that we've decided, in our MyStatus application, that when a user creates a new
account, we also require them to create an initial status update. In this workflow, we'll end
up creating a new user record at the same time as when we create their first status update,
which is to say that we'll be populating all the columns of the
users_with_status_updates table in a single statement:
INSERT INTO "users_with_status_updates"
("username", "id", "email", "encrypted_password", "body")
VALUES (
'alice',
76e7a4d0-e796-11e3-90ce-5f98e903bf02,
'alice@gmail.com',
0x8914977ed729792e403da53024c6069a9158b8c4,
'Learning Cassandra!'
);
It's worth emphasizing that even though this is a single INSERT statement, we're actually
doing two separate things:
• Assigning the email and encrypted_password values to every row whose
username value is alice
• Creating a new row in the alice partition, with Learning Cassandra! as
the value of body
Let's take a look at the contents of the table so far:
SELECT * FROM "users_with_status_updates";
Looking at the output, we'll observe that it's just what we'd expect (I've omitted the en-
crypted_password column to save space):
Search WWH ::




Custom Search