Overview for an Acquainted SQL Acquaintance Moving to Cassandra / NoSQL

After many years of working with relational databases, I’m confidently brainwashed innormalized to think about tables, columns and rows. Cassandra still escapes my mind completely wrapping it.

I understand its more persistent cards, and you can only ask for unique keys for these cards, but my understanding is incomplete.

Yes, I am RTFM. However, can someone give me a nice, brief description of how Cassandra structure data compares with SQL db? I mean, 1000 feet, how does it work differently?

For example, an ebay tech blog says:

Do not think about a relational table.

Instead, think of a nested, sorted map data structure. Source: http://www.ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/

And I understand him almost completely ... but not quite.


These are great answers. Added generosity to see if it inspires anyone to make an even more authoritative answer.

+4
source share
3 answers

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.
+6

, ( ).

Cassandra ( HBase, ) , /. .

, ( " " ), , . " ", . , , , . , , , / .

+2

. :

, Cassandra node, . Cassandra ..: http://www.slideshare.net/planetcassandra/a-deep-dive-into-understanding-apache-cassandra

- , SQL/Cassandra / , :

  • SQL ( prod, ) . Cassandra
  • Cassandra , . SQL DB .
  • Cassandra, , .
  • With Cassandra, it’s easy to get rid of SPOF (single point failure) because it has built-in replication without a wizard. In SQL databases, you often have Master-Slave replication, where Master is SPOF. Master-Master solutions in the SQL world are quite complex and have their own problems. It's much easier to implement scalable, highly available systems with limited Cassandra operations. SQL DB is much more efficient in terms of data processing functionality, while it has its own costs.
  • and much more..
+2
source

All Articles