Database Reference
In-Depth Information
NOTE
I'm leaving out the timestamp attribute of the columns here for simplicity, but just remember that every
column has a timestamp.
In this example, the row key is a unique primary key for the hotel, and the columns are name,
phone, address, city, state, and zip. Although these rows happen to define values for all of the
same columns, you could easily have one row with 4 columns and another row in the same
column family with 400 columns, and none of them would have to overlap.
NOTE
It's an inherent part of Cassandra's replica design that all data for a single row must fit on a single ma-
chine in the cluster. The reason for this limitation is that rows have an associated row key, which is used
to determine the nodes that will act as replicas for that row. Further, the value of a single column cannot
exceed 2GB. Keep these things in mind as you design your data model.
We can query a column family such as this one using the CLI, like this:
cassandra> get Hotelier.Hotel['NYN_042']
=> (column=zip, value=10019, timestamp=3894166157031651)
=> (column=state, value=NY, timestamp=3894166157031651)
=> (column=phone, value=212-555-5555, timestamp=3894166157031651)
=> (column=name, value=The Waldorf=Astoria, timestamp=3894166157031651)
=> (column=city, value=New York, timestamp=3894166157031651)
=> (column=address, value=301 Park Ave, timestamp=3894166157031651)
Returned 6 results.
This indicates that we have one hotel in New York, New York, but we see six results because the
results are column-oriented, and there are six columns for that row in the column family. Note
that while there are six columns for that row, other rows might have more or fewer columns.
Column Family Options
There are a few additional parameters that you can define for each column family. These are:
keys_cached
keys_cached
The number of locations to keep cached per SSTable. This doesn't refer to column name/
values at all, but to the number of keys, as locations of rows per column family, to keep in
memory in least-recently-used order.
Search WWH ::




Custom Search