Upload
tristan-gomez
View
271
Download
2
Tags:
Embed Size (px)
Citation preview
Document Databases and Key-Value Stores
a.k.a “pump it and dump it”
Thursday, April 25, 13
~/$ whoami
Thursday, April 25, 13
@parasquid (also in fb/github)
works (here) at Mindvalley
helps organize KLMUG with Mark
did my rounds (from servers to frontend and back)
settled in as an app developer
Thursday, April 25, 13
A MagicalHistory Tour
Thursday, April 25, 13
Thursday, April 25, 13
two years ago
joffrey was the first mongo-based prototype Mindvalley in Mindvalley
oathkeeper was the second
got used in production
still in production (unfortunately)
Thursday, April 25, 13
Quick Review on Advantages of NoSQL over
Relational Databases
Thursday, April 25, 13
Relational
Impedance Mismatch
An order, which looks like a single aggregate structure in the UI, is split into many rows from many tables
Thursday, April 25, 13
NoSQLModel alignment
The storage data model closely resembles how the aggregate is represented in the domain (especially in document databases)
Thursday, April 25, 13
RelationalProgrammer Productivity
Before you can modify your data model, you first have to think of how to tear it apart and make a migration
Thursday, April 25, 13
NoSQL
Programmer Productivity
Most of the adjustments to the db are transparent; non-existent keys just return nil
Thursday, April 25, 13
Quick Recap on the difference between Relational and NoSQL
(k-v and doc)
Thursday, April 25, 13
Relational: blows up a model into small, constituent data
NoSQL (k-v and doc): stores and retrieves aggregates
Thursday, April 25, 13
VS
Thursday, April 25, 13
Key-Value Stores and Document Databases
Thursday, April 25, 13
they actually are not that much different conceptually
mostly: you store and access a key-value store via a key (but not always)
mostly: you store and access a document database via a query (but not always)
Thursday, April 25, 13
Thursday, April 25, 13
Thursday, April 25, 13
key-value store
aggregate is opaque to the database
db doesn’t care about the structure
document db
database knows the structure
db knows this field is a string/date/integer/etc
Difference
Thursday, April 25, 13
Differencekey-value store
we can store whatever we like in the db
same field names may hold different types of objects
document db
defines allowable structures and types
structure supports flexibility
Thursday, April 25, 13
I’ve never useda column db before sono comments on that :)
Thursday, April 25, 13
But first, a word about “Schema-less”
Thursday, April 25, 13
I actually prefer the term“schema-free”
once you start querying data, your data starts to have an implicit schema
“schema-free” is great for non-uniform data but you need some structure if you want to start querying for data
Thursday, April 25, 13
NoSQL shifts the schema into the application code that accesses it
this can be a good thing or a bad thing
Thursday, April 25, 13
Sample Use-cases
Thursday, April 25, 13
Key-Value Storeswhen to use:
session data
user preferences
shopping cart data
when NOT to use:
relationships among data
multi-operation transactions
query by data
Thursday, April 25, 13
Document Databaseswhen to use:
event logging
content management systems / blogging platforms
web analytics
e-commerce
when NOT to use:
complex transactions spanning different operations
queries against varying aggregate structure
Thursday, April 25, 13
VS
Thursday, April 25, 13
Conclusion
use the right tool for the right job
look at the tradeoffs and decide accordingly
in the end, it’s a business decision (supported by technical capabilities)
Thursday, April 25, 13