Database Reference
In-Depth Information
Inserts can overwrite existing data
Let's add a fifth user to our application, eve . We'll sign her up with a full complement of
profile fields:
INSERT INTO "users"
("username", "email", "encrypted_password", "location")
VALUES
('eve', 'eve@gmail.com',
0x85e36ed9f726295921a4a6f40d95c202c895180c,
'Washington, D.C.');
On checking the users table, we can confirm that eve has the data we intended:
Now let's imagine that another user, also named eve , would like to use MyStatus. If we
naïvely allow her to choose any username she wants, we will end up attempting to create
her username like this:
INSERT INTO "users"
("username", "email", "encrypted_password")
VALUES
('eve', 'eve123@hotmail.com',
0x411ebd49a24f8be2250c527160509264622d7883);
Intuitively, we would expect this statement to generate an error because we're trying to in-
sert a row with the primary key eve , which is already assigned to an existing row. In fact,
Cassandra will report no such error and, much to our horror, we'll find that we've overwrit-
ten data from the first eve 's profile:
Search WWH ::




Custom Search