Database Reference
In-Depth Information
Design Differences Between RDBMS and Cassandra
There are several differences between Cassandra's model and query methods compared to what's
available in RDBMS, and these are important to keep in mind.
No Query Language
SQL is the standard query language used in relational databases. Cassandra has no query lan-
guage. It does have an API that you access through its RPC serialization mechanism, Thrift.
No Referential Integrity
Cassandra has no concept of referential integrity, and therefore has no concept of joins. In a rela-
tional database, you could specify foreign keys in a table to reference the primary key of a record
in another table. But Cassandra does not enforce this. It is still a common design requirement to
store IDs related to other entities in your tables, but operations such as cascading deletes are not
available.
Secondary Indexes
Here's why secondary indexes are a feature: say that you want to find the unique ID for a hotel
property. In a relational database, you might use a query like this:
SELECT hotelID FROM Hotel WHERE name = 'Clarion Midtown';
This is the query you'd have to use if you knew the name of the hotel you were looking for but
not the unique ID. When handed a query like this, a relational database will perform a full table
scan, inspecting each row's name column to find the value you're looking for. But this can be-
come very slow once your table grows very large. So the relational answer to this is to create an
index on the name column, which acts as a copy of the data that the relational database can look
up very quickly. Because the hotelID is already a unique primary key constraint, it is automat-
ically indexed, and that is the primary index; for us to create another index on the name column
would constitute a secondary index, and Cassandra does not currently support this.
To achieve the same thing in Cassandra, you create a second column family that holds the lookup
data. You create one column family to store the hotel names, and map them to their IDs. The
second column family acts as an explicit secondary index.
Search WWH ::




Custom Search