Database Reference
In-Depth Information
Figure3-1.A list of values
If you persisted this list, you could query it later, but you would have to either examine each
value in order to know what it represented, or always store each value in the same place in the
list and then externally maintain documentation about which cell in the array holds which values.
That would mean you might have to supply empty placeholder values (nulls) in order to keep the
uniform size in case you didn't have a value for an optional attribute (such as a fax number or
apartment number). An array is a clearly useful data structure, but not semantically rich.
So we'd like to add a second dimension to this list: names to match the values. We'll give names
to each cell, and now we have a map structure, as shown in Figure 3-2 .
Figure3-2.A map of name/value pairs
This is an improvement because we can know the names of our values. So if we decided that our
map would hold User information, we could have column names like firstName , lastName ,
phone , email , and so on. This is a somewhat richer structure to work with.
But the structure we've built so far works only if we have one instance of a given entity, such as
a single Person or User or Hotel or Tweet. It doesn't give us much if we want to store multiple
entities with the same structure, which is certainly what we want to do. There's nothing to unify
some collection of name/value pairs, and no way to repeat the same column names. So we need
something that will group some of the column values together in a distinctly addressable group.
We need a key to reference a group of columns that should be treated together as a set. We need
rows. Then, if we get a single row, we can get all of the name/value pairs for a single entity at
once, or just get the values for the names we're interested in. We could call these name/value
pairs columns. We could call each separate entity that holds some set of columns rows. And the
unique identifier for each row could be called a row key.
Cassandra defines a columnfamilyto be a logical division that associates similar data. For ex-
ample, we might have a User column family, a Hotel column family, an AddressBook column
Search WWH ::




Custom Search