Note. Since the original question concerned Cassandra, this will be the focus of this answer. Although Cassandra and other non-relational (NoSQL) data warehouses often have similar concepts, it cannot be assumed that the ideas presented here will work with other non-relational data warehouses.
- , ( Cassandra) . , . Cassandra () , , . ... . DataStax Cassandra .
, :
CREATE TABLE users (
username TEXT,
firstname TEXT,
lastname TEXT,
phone TEXT,
PRIMARY KEY (username));
:
username | firstname | lastname | phone
------------------------------------------------
mreynolds | Malcolm | Reynolds | 111-555-1234
jcobb | Jayne | Cobb | 111-555-3464
sbook | Derial | Book | 111-555-2349
stam | Simon | Tam | 111-555-8899
users username, PRIMARY KEY. , ? phone, phone, , , username. - , . . , username phone .
CREATE TABLE usersbyphone (
phone TEXT,
username TEXT,
firstname TEXT,
lastname TEXT,
PRIMARY KEY (phone));
, "Hoban Washburne" "Zoe Washburne". , () . Cassandra ( ). usersbyphone, :
PRIMARY KEY (phone,username));
phone - (, , ), username - (, ). . usersbyphone :
SELECT username, firstname, lastnamea, phone FROM usersbyphone;
username | firstname | lastname | phone
------------------------------------------------
hwashburne| Hoban | Washburne| 111-555-1212
jcobb | Jayne | Cobb | 111-555-3464
mreynolds | Malcolm | Reynolds | 111-555-1234
sbook | Derial | Book | 111-555-2349
stam | Simon | Tam | 111-555-8899
zwashburne| Zoe | Washburne| 111-555-1212
, usersbyphone users... . , users, usersbyphone. , , , . , , .
DataStax MVP ( , CQL3 Maps Cassandras), Casssandra users , :
RowKey:mreynolds
=> (column=, value=, timestamp=1374546754299000)
=> (column=firstname, value=Malcolm, timestamp=1374546754299000)
=> (column=lastname, value=Reynolds, timestamp=1374546754299000)
=> (column=phone, value=111-555-1234, timestamp=1374546754299000)
------------------------------------------------------
RowKey:hwashburne
=> (column=, value=, timestamp=1374546757815000)
=> (column=firstname, value=Hoban, timestamp=1374546757815000)
=> (column=lastname, value=Washburne, timestamp=1374546757815000)
=> (column=phone, value=111-555-1212, timestamp=1374546757815000)
------------------------------------------------------
RowKey:zwashburne
=> (column=, value=, timestamp=1374546761055000)
=> (column=firstname, value=Zoe, timestamp=1374546761055000)
=> (column=lastname, value=Washburne, timestamp=1374546761055000)
=> (column=phone, value=111-555-1212, timestamp=1374546761055000)
Map-of-a-Map ( eBay) . usersbyphone users:
RowKey:111-555-1234
=> (column=mreynolds, value=, timestamp=1374546754299000)
=> (column=mreynolds:firstname, value=Malcolm, timestamp=1374546754299000)
=> (column=mreynolds:lastname, value=Reynolds, timestamp=1374546754299000)
------------------------------------------------------
RowKey:111-555-1212
=> (column=hwashburne, value=, timestamp=1374546757815000)
=> (column=hwashburne:firstname, value=Hoban, timestamp=1374546757815000)
=> (column=hwashburne:lastname, value=Washburne, timestamp=1374546757815000)
=> (column=zwashburne, value=, timestamp=1374546761055000)
=> (column=zwashburne:firstname, value=Zoe, timestamp=1374546761055000)
=> (column=zwashburne:lastname, value=Washburne, timestamp=1374546761055000)
- , Wash (hwashburne) Zoe (zwashburne) . , .
:
- ( ) . .
- Cassandra .
- Cassandra () .
- Cassandra . ( ).
- CQL (Cassandra Query Language) - SQL. CQL , RDBMS , , SQL CQL.