Databases Reference
In-Depth Information
A
B
C
Figure 4.18 Using a
row and column to
address a cell. The cell
has an address of 3B
and can be thought of as
the lookup key in a
sparse matrix system.
1
2
3
Hello World!
4
5
6
4.3.1
Column family basics
Our first example of using rows and columns as a key is the spreadsheet. Though most
of us don't think of spreadsheets as a NoSQL technology, they serve as an ideal way to
visualize how keys can be built up from more than one value. Figure 4.18 shows a
spreadsheet with a single cell at row 3 and column 2 (the B column) that contains the
text “Hello World!”
In a spreadsheet, you use the combination of a row number and a column letter as
an address to “look up” the value of any cell. For example, the third column in the sec-
ond row in the figure is identified by the key C2 . In contrast to the key-value store,
which has a single key that identifies the value, a spreadsheet has row and column
identifiers that make up the key. But like the key-value store, you can put many differ-
ent items in a cell. A cell can contain data, a
formula, or even an image. The model for this
is shown in figure 4.19.
This is roughly the same concept in column
family systems. Each item of data can only be
found by knowing information about the row
and column identifiers. And, like a spread-
sheet, you can insert data into any cell at any
time. Unlike an RDBMS , you don't have to
insert all the column's data for each row.
Key
Row
number
Column
letter
Value
Figure 4.19 Spreadsheets use a row-
column pair as a key to look up the value
of a cell. This is similar to using a key-
value system where the key has two parts.
Like a key-value store, the value in a cell
may take on many types such as strings,
numbers, or formulas.
4.3.2
Understanding column family keys
Now that you're comfortable with slightly more complex keys, we'll add two additional
fields to the keys from the spreadsheet example. In figure 4.20 you can see we've
added a column family and timestamp to the key.
Key
Column
family
Column
name
Row-ID
Timestamp
Value
Figure 4.20 The key structure in column family stores is similar to a
spreadsheet but has two additional attributes. In addition to the
column name, a column family is used to group similar column names
together. The addition of a timestamp in the key also allows each cell
in the table to store multiple versions of a value over time.
 
Search WWH ::




Custom Search