Buscar

domingo, 23 de noviembre de 2014

MongoDB for developers 1/8. Introduction

What is MongoDB?

MongoDB is document oriented.
MongoDB has dynamic schema.


Mongo Relative to Relational




Which features did MongoDB omit in order to retain scalability?
Joins
Transactions across multiple collections

The following are valid JSON documents
{a:1, b:2, c: 3}
{a:1, b:2, c:[1,2,3,4,5]}
{a:1, b:{}, c: [ { a:1, b:2}, 5, 6]}
{ }

JSON Arrays

Write the JSON for a simple document containing a single key "fruit" that has as its value an array containing three strings: "apple", "pear", and "peach"
{fruit: ["apple","pear","peach"]}

JSON Subdocuments

Write a JSON document with a single key, "address" that has as it value another document with the keys 'street_address', 'city', 'state', 'zipcode', with the following values: 'street_address' is "23 Elm Drive", 'city' is "Palo Alto", 'state' is "California", 'zipcode' is "94305"
{'address': {'street_address': "23 Elm Drive", 'city' : "Palo Alto", 'state': "California", 'zipcode': "94305"} }

Blog in Relational Tables

let’s assume that our blog can be modeled with the following relational tables:
authors:
 author_id,
 name,
 email,
 password

posts:
 post_id,
 author_id
 title,
 body, 
 publication_date

comments:
 comment_id,
 name, 
 email,
 comment_text

post_comments:
 post_id,
 comment_id


tags
 tag_id
 name

post_tags
 post_id
 tag_id
In order to display a blog post with its comments and tags, how many tables will need to be accessed?
6

Blog in Documents

Given the document schema that we proposed for the blog, how many collections would we need to access to display the blog home page?
1


Intro to Schema Design

In which scenario is it impossible to embed data within a document (you must put the data in it a separate collection). Check all that apply.
The embedded data could exceed the 16MB document limit within MongoDB

No hay comentarios:

Publicar un comentario