Vous êtes sur la page 1sur 66

MongoDB

Schema Design
MongoNYC (#mongonyc) May 21, 2010 Kyle Banker (@hwaet) 10gen
http://www.mongodb.org/
Tuesday, May 25, 2010

1. Schema Design Questions


Tuesday, May 25, 2010

Whats the basic unit of data?

Tuesday, May 25, 2010

Whats the basic unit of data?


Blobs?

Tuesday, May 25, 2010

Whats the basic unit of data?


Blobs? Rows?

Tuesday, May 25, 2010

Whats the basic unit of data?


Blobs? Rows? Columns?

Tuesday, May 25, 2010

Whats the basic unit of data?


Blobs? Rows? Columns? Documents?
Tuesday, May 25, 2010

Which operations are permitted?

Tuesday, May 25, 2010

Which operations are permitted?


Dynamic Queries

Tuesday, May 25, 2010

Which operations are permitted?


Dynamic Queries Secondary Indexes

Tuesday, May 25, 2010

Which operations are permitted?


Dynamic Queries Secondary Indexes Atomic Updates

Tuesday, May 25, 2010

Which operations are permitted?


Dynamic Queries Secondary Indexes Atomic Updates Map-Reduce
Tuesday, May 25, 2010

What are our application access patterns?

Tuesday, May 25, 2010

What are our application access patterns?


Read / Write Ratio

Tuesday, May 25, 2010

What are our application access patterns?


Read / Write Ratio Types of updates

Tuesday, May 25, 2010

What are our application access patterns?


Read / Write Ratio Types of updates Range of Queries
Tuesday, May 25, 2010

2. Rich Documents

Tuesday, May 25, 2010

Tuesday, May 25, 2010

Tuesday, May 25, 2010

Tuesday, May 25, 2010

But what can you do with a rich document?

Tuesday, May 25, 2010

Queries

Tuesday, May 25, 2010

Queries

Tuesday, May 25, 2010

Queries

Tuesday, May 25, 2010

Atomic Updates

Tuesday, May 25, 2010

Atomic Updates

Tuesday, May 25, 2010

Map-Reduce

Tuesday, May 25, 2010

More rich-document goodness...

Tuesday, May 25, 2010

wordnik.com

Tuesday, May 25, 2010

Advantages
Pre-joined for fast retrieval.

Tuesday, May 25, 2010

Advantages
Pre-joined for fast retrieval. Holistic representation.

Tuesday, May 25, 2010

Advantages
Pre-joined for fast retrieval. Holistic representation. MongoDB can act on these.

Tuesday, May 25, 2010

Tradeos
The Normalization / Denormalization Question

Tuesday, May 25, 2010

Tradeos
The Normalization / Denormalization Question Know your queries / updates in advance

Tuesday, May 25, 2010

2. Simplied Relations

Tuesday, May 25, 2010

Tags

Tuesday, May 25, 2010

Tags

Tuesday, May 25, 2010

Tags

Tuesday, May 25, 2010

Votes

Tuesday, May 25, 2010

Adding a vote

Tuesday, May 25, 2010

Adding a vote

Finding all votes for a given user

Tuesday, May 25, 2010

4. Standard Relationships
Tuesday, May 25, 2010

post -> many comments


Relational model:
post comments
post_id user_id tree attrs

Tuesday, May 25, 2010

1. Embedded Document

Tuesday, May 25, 2010

1. Embedded Document

Tuesday, May 25, 2010

2. Embedded and Nested Document

Tuesday, May 25, 2010

3. Normalized Collection

Tuesday, May 25, 2010

Use Cases 1. Embedded document Fast queries Document always appears w/ parent.

Tuesday, May 25, 2010

Use Cases 1. Embedded document Fast queries Document always appears w/ parent. 2. Embedded & nested document Complex hierarchies Document appears with parent

Tuesday, May 25, 2010

Use Cases 1. Embedded document Fast queries Document always appears w/ parent. 2. Embedded & nested document Complex hierarchies Document appears with parent 3. Normalized Maximum exibility. Simplied global updates.
Tuesday, May 25, 2010

Tuesday, May 25, 2010

products <-> categories


Relational model:
products join
product_id category_id

categories

Tuesday, May 25, 2010

Products and Categories

Tuesday, May 25, 2010

Products and Categories

Tuesday, May 25, 2010

Products and Categories (Alternative)

Tuesday, May 25, 2010

Products and Categories (Alternative)

Tuesday, May 25, 2010

Products and Categories (Alternative)

Tuesday, May 25, 2010

5. Resources

Tuesday, May 25, 2010

Trees
http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

Tuesday, May 25, 2010

Trees
http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

Stacks, Queues, Lists


http://www.mongodb.org/display/DOCS/ndandmodify+Command

Tuesday, May 25, 2010

Trees
http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

Stacks, Queues, Lists


http://www.mongodb.org/display/DOCS/ndandmodify+Command

Contribute
http://cookbook.mongodb.org

Tuesday, May 25, 2010

Trees
http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

Stacks, Queues, Lists


http://www.mongodb.org/display/DOCS/ndandmodify+Command

Contribute
http://cookbook.mongodb.org

Consulting
info@10gen.com

Tuesday, May 25, 2010

6. Shameless Plugs

Tuesday, May 25, 2010

MongoDB Training | July 7-8


http://ideafoundry.info/mongodb
Tuesday, May 25, 2010

My next talk today.....

MongoDB in Rubys Embrace


MongoNYC (#mongonyc) May 21, 2010 Kyle Banker (@hwaet) 10gen
http://www.mongodb.org/
Tuesday, May 25, 2010

Thank You

http://www.mongodb.org/
Tuesday, May 25, 2010

Vous aimerez peut-être aussi