Database Reference
In-Depth Information
Sets
Cassandra sets provide a means of keeping a unique set of items without the need
for read-before-write. This means that one can easily solve the problem of tracking
unique e-mail addresses or unique IP addresses. Lists are ordered by the natural
order of the type selected. Listing 3.9 shows how to create a table with a set type
and query it.
Listing 3.9 Example of Using a Set
Click here to view code image
CREATE TABLE users (
email TEXT PRIMARY KEY,
portfolios SET@UUID:,
tickers SET@TEXT:
);
UPDATE users
SET portfolios = portfolios +
{756716f7-2e54-4715-9f00-91dcbea6cf50},
tickers = tickers + {'AMZN'}
WHERE email = 'foo@bar.com';
UPDATE users
SET portfolios = portfolios +
{756716f7-2e54-4715-9f00-91dcbea6cf50},
tickers = tickers + {'GOOG'}
WHERE email = 'foo@bar.com';
email | portfoli-
os | tickers
.............+........................................+.................
foo@bar.com |
{756716f7-2e54-4715-9f00-91dcbea6cf50} | {'AMZN',
'GOOG'}
UPDATE users
SET tickers = tickers - {'AMZN'}
WHERE email = 'foo@bar.com';
email
| portfoli-
os
| tickers
 
Search WWH ::




Custom Search