Zero to Sixty with
MongoDB and PHP

Jeremy Mikola
jmikola

Starting Off

  • What sets MongoDB apart?
  • What are documents?
  • How do we get up and running?
  • What's in a driver?
  • How do we read/write documents?
  • What else can we do?

Database Landscape

  • Memcached
  • Key/Value
  • MongoDB
  • RDBMS
Scalability and Performance
Depth of Functionality

Relational Modeling

articles
id author_id title body
1 2 Praesent ante dui Lorem ipsum…
articles_to_tags
id article_id tag_id
36 1 7
37 1 8
authors
id name email
2 Bob bob@example.com
3 John john@example.com
comments
id article_id author_id body
4 1 3 Morbi libero erat…
5 1 2 Dapibus quis…
6 1 3 Fusce fermentum…
tags
id name
7 luctus
8 rhoncus

Things May Get
Out of Hand

Getting Up and Running with Mongo

In 60 Seconds

* Excluding download time :)

Let's Get Cooking

Identifiers and Types

What's in an ObjectID?

57f7d220 da14d8 03b9 4fba92
Timestamp Hostname PID Sequence
  • 12-byte, binary string
  • Safely generated in distributed environments
  • Timestamp prefix useful for sorting

Writing

Queries

An Atomic Pickle

  • We can query for things
  • We can update documents atomically
  • Can we atomically query and update?

Indexing

Database Commands

Aggregation

GridFS