Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MongoDB at Fiesta

Mike Dirolf
November 16, 2011

MongoDB at Fiesta

Slides from a NY MongoDB User Group talk given on 11/16/2011. The talk was about lessons we've learned while using MongoDB at Fiesta. The bulk of the talk was an overview on data modeling with MongoDB, since that is an issue that tends to come up frequently with new users.

Mike Dirolf

November 16, 2011
Tweet

More Decks by Mike Dirolf

Other Decks in Technology

Transcript

  1. Cc: Subject: To: Good article [email protected], [email protected], [email protected], [email protected] Thought

    you guys might enjoy this article: http://nymag.com/arts/books/features/jeffrey-eugenides
  2. Cc: Subject: To: [email protected], [email protected], [email protected], [email protected] family@fiesta.cc Good article

    Thought you guys might enjoy this article: http://nymag.com/arts/books/features/jeffrey-eugenides
  3. 0-embed {    _id:  PERSON_ID,    name:  "Mike  Dirolf",  

     pw:  "Some  Hashed  Password" } Person
  4. 0-embed {    _id:  MEMBERSHIP_ID,    person:  PERSON_ID,    group:

     GROUP_ID,    address:  ADDRESS_ID,    group_name:  "family" } Membership
  5. 0-embed Other member addresses for an address & group_name: 1.

     var  x  =  db.addresses.findOne({address:  address}) 2.  var  y  =  db.memberships.findOne({person:  x.person,                                                                group_name:  group_name}) 3.  var  z  =  db.memberships.find({group:  y.group}) 4.  for  m  in  z:  db.addresses.findOne({person:  m.person})
  6. Embed Everything {    _id:  GROUP_ID,    domain:  "gitlists.com",  

     memberships:  [{        address:  "[email protected]",        name:  "Mike  Dirolf",        pw:  "Some  Hashed  Password",        person_addresses  =            ["[email protected]",              "[email protected]",              ...],        group_name:  "family"    },  ...] }
  7. Embed Everything Other member addresses for an address & group_name:

    db.groups.findOne({memberships:                                        {$elemMatch:                                            {address:  address,                                              group_name:  group_name}}})
  8. Embed Trivial Cases {    _id:  PERSON_ID,    name:  "Mike

     Dirolf",    pw:  "Some  Hashed  Password",    addresses:  ["[email protected]",                            "[email protected]",  ...],    memberships:  [{        address:  "[email protected]",        group_name:  "family",        group:  GROUP_ID    },  ...] }
  9. Embed Trivial Cases Other member addresses for an address &

    group_name: 1.  var  x  =  db.users.findOne({address:  address,                                                          "groups.name":  group_name}) 2.  db.users.find({"groups.id":  ...})