Databases Reference
In-Depth Information
There are few restrictions
about what you can use as a key as
long as it's a reasonably short
string of characters. There are also
few restrictions about what types
of data you can put in the value of
a key-value store. As long as your
storage system can hold it, you can
store it in a key-value store, mak-
ing this structure ideal for multi-
media: images, sounds, and even
full-length movies.
Traditional relational model
￿ Result set based on row values
￿ Values of rows for large datasets
must be indexed
￿ Values of columns must all have
the same data type
Key-value store model
￿ All queries return a single item
￿ No indexes on values
￿ Values may contain any data type
Figure 4.7 The trade-offs associated with traditional
relational models (which focus on the database layer)
versus key-value store models (which focus on the
application layer).
G ENERAL PURPOSE
In addition to being simple, a key-
value store is a general-purpose
tool for solving business problems. It's the Swiss Army knife of databases. What
enables the generality is the ability for the application programmer to define what
their key structures will be and what type of data they're going to store in the values.
Now that we've looked at the benefits and uses of a key-value store, we'll look at
two use case examples. The first, storing web pages in a key-value store, shows how web
search engines such as Google easily store entire websites in a key-value store. So if you
want to store external websites in your own local database, this type of key-value store
is for you.
The second use case, Amazon simple storage service (S3), shows how you can use a
key-value store like S3 as a repository for your content in the cloud. If you have digital
media assets such as images, music, or video, you should consider using a key-value
store to increase the reliability and performance for a fraction of the cost.
4.1.4
Use case: storing web pages in a key-value store
We're all familiar with web search engines, but you may not realize how they work.
Search engines like Google use a tool called a web crawler to automatically visit a web-
site to extract and store the content of each web page. The words in each web page
are then indexed for fast keyword search.
When you use your web browser, you usu-
ally enter a web address such as http://
www.example.com/hello.html . This uniform
resource locator , or URL , represents the key of a
website or a web page. You can think of the
web as a single large table with two columns,
as depicted in figure 4.8.
The URL is the key, and the value is the
web page or resource located at that key. If
Key
Value
http://www.example.com/index.html
<html>…
http://www.example.com/about.html
<html>…
http://www.example.com/products.html
<html>…
http://www.example.com/logo.png
Binary…
Figure 4.8 How you can use URLs as a key in a
key-value store. Since each web page has a
unique URL, you can be assured that no two web
pages have the same URL.
Search WWH ::




Custom Search