3. { {{ {{{ NoSQL }}} }} }
* GONG *
Tuesday, December 14, 2010 3
4. NoSQL
So... What is it?
Tuesday, December 14, 2010 4
5. NoSQL
⢠Itâs âNot SQLâ
⢠Less Structured; Sometimes Un-Structured
⢠Usually Implies:
⢠Key-Value Store
⢠Document Datastore
⢠Graph Databases (and its Variants)
⢠Often not much more than that
Tuesday, December 14, 2010 5
6. NoSQL
Recap and Comparison
Tuesday, December 14, 2010 6
7. NoSQL
SELECT persons.*
FROM persons
LEFT JOIN automobiles
ON persons.id = automobiles.person_id
WHERE automobiles.color IS 'RED'
/* Wait! We can NORMALIZE this some more! */
SELECT persons.*
FROM persons
LEFT JOIN automobiles
LEFT JOIN colors
ON persons.id = automobiles.person_id
AND colors.id = automobiles.color_id
WHERE colors.name IS 'RED-34'
/* Wait! ... */
Tuesday, December 14, 2010 7
8. NoSQL
SELECT persons.*
FROM persons
LEFT JOIN automobiles
ON persons.id = automobiles.person_id
WHERE automobiles.color IS 'RED'
/* Wait! We can NORMALIZE this some more! */
SELECT persons.*, automobiles.* /* Selects */
FROM persons
LEFT JOIN automobiles /* Joins */
LEFT JOIN colors
ON persons.id = automobiles.person_id
AND colors.id = automobiles.color_id
WHERE colors.name IS 'RED-34' /* Conditions */
/* Wait! ... */
Tuesday, December 14, 2010 8
9. Persons
NoSQL Colors
id First Name Last Name id name
1 Seymore Butts 212 RED-34
2 Amanda Hugginkiss 213 BLUE-32
Join Table => PersonsVehicles
id vehicle_id person_id color_id
1 7384 1 212
2 7231 2 212
Automobiles
id make model Year
23192 Honda Civic 2003
19763 Chevy Tahoe 1998
Relationship: âBelongs Toâ => Vehicles
id identiďŹer automobile_id
Normalization 7231
7384
1FALP62W4WH128703
4WH1287031FALP62W
23192
19763
Tuesday, December 14, 2010 9
10. NoSQL
Key-Value Stores
AKA: Dictionary,
Hash Table, etc.
KV Database
Key Give me whatâs at âJohnâ
âJohnâ
âJo
hn
â
Value at âJohnâ
âSmithâ
âSmithâ
Tuesday, December 14, 2010 10
11. NoSQL
Key-Value Stores
⢠Very Fast
⢠Simple
⢠Key-Value Pairs are Self-Contained
â´Easier Replication
- Twitter, Facebook, Google, etc.
- Also,Your Computer
Tuesday, December 14, 2010 11
12. NoSQL
Document[-Oriented] Stores
Very De-Normalized Less De-Normalized
âJohn Smithâ âJohn Smithâ
string ďŹrst_name John string ďŹrst_name John
string last_name Smith string last_name Smith
embedded automobiles embedded automobiles
document doc_id make Honda document doc_ref vehicle id(fd18d0af6c053886d)
string model Civic string color Red
int year 2003 string employer Epoch, LLC.
string color Red
fd18d0af6c053886d
string employer Epoch, LLC.
string make Honda
string model Civic
int year 2003
embedded features
document string breaks anti-lock
bool air_cond TRUE
geo_coord made_at 39.975542, -82.992096
Tuesday, December 14, 2010 12
13. NoSQL
Document[-Oriented] Stores
⢠Analogous to Printed Documents
⢠Varying Levels of De-normalization
⢠Documents Still Relatively Self-Contained
â´Easier Replication, Too
- Twitter, Facebook, Google, etc.
Tuesday, December 14, 2010 13
14. NoSQL
Graph Databases
untitled
6
4 5
1
3 2
Six Degrees of Separation
or: How you realized you have no friends :-(
Tuesday, December 14, 2010 14
15. NoSQL
Graph Databases
⢠Relationships Derived Through âDistanceâ
⢠Some Use-Cases:
⢠Geographic
⢠Networking
⢠Routing / Shortest Path
⢠Social
⢠Molecular Modeling
⢠Kevin Bacon Jokes
⢠Also Quite Trendy:
- Twitter, Facebook, Google [Maps, Mail, & Your Life]
Tuesday, December 14, 2010 15
16. NoSQL
Letâs Explore: redis
Tuesday, December 14, 2010 16