SlideShare uma empresa Scribd logo
1 de 58
Thinking In Documents
Buzz Moschetti
Enterprise Architect, MongoDB
buzz.moschetti@mongodb.com
@buzzmoschetti
Before We Begin
• This webinar is being recorded
• Use The Chat Window for
• Technical assistance
• Q&A
• MongoDB Team will answer quick
questions in realtime
• “Common” questions will be
reviewed at the end of the webinar
Theme #1:
Great Data Design involves
much more than the database
• Easily understood structures
• Harmonized with software
• Acknowledging legacy issues
Theme #2:
Today’s solutions need to
accommodate tomorrow’s needs
• End of “Requirements Complete”
• Ability to economically scale
• Shorter solutions lifecycles
Theme #3:
MongoDB offers you choice
RDBMS MongoDB
Database Database
Table Collection
Index Index
Row Document
Column Field
Join Embedding & Linking
Terminology
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
authors: [
{ _id: "kchodorow", name: "Kristina Chodorow“ },
{ _id: "mdirold", name: “Mike Dirolf“ }
],
published_date: ISODate(”2010-09-24”),
pages: 216,
language: "English",
thumbnail: BinData(0,"AREhMQ=="),
publisher: {
name: "O’Reilly Media",
founded: 1980,
locations: ["CA”, ”NY” ]
}
}
What is a Document?
// Java: maps
DBObject query = new BasicDBObject(”publisher.founded”, 1980));
Map m = collection.findOne(query);
Date pubDate = (Date)m.get(”published_date”); // java.util.Date
// Javascript: objects
m = collection.findOne({”publisher.founded” : 1980});
pubDate = m.published_date; // ISODate
year = pubDate.getUTCFullYear();
# Python: dictionaries
m = coll.find_one({”publisher.founded” : 1980 });
pubDate = m[”pubDate”].year # datetime.datetime
Documents Map to Language Constructs
9
Traditional Data Design
• Static, Uniform Scalar Data
• Rectangles
• Low-level, physical
representation
10
Document Data Design
• Flexible, Rich Shapes
• Objects
• Higher-level, business
representation
Schema Design By
Example
12
Library Management Application
• Patrons/Users
• Books
• Authors
• Publishers
13
Question:
What is a Patron’s Address?
Patron + Address: Initial Attempt
> db.patrons.find({ _id : “joe” })
{
_id: "joe“,
name: "Joe Bookreader”,
favoriteGenres: [ ”mystery”, ”programming” ]
}
> db.addresses.find({ _id : “joe” })
{
_id: "joe“,
street: "123 Fake St.",
city: "Faketon",
state: "MA",
zip: “12345”
}
Patron + Address: The MongoDB Way
> db.patrons.find({ _id : “joe” })
{
_id: "joe",
name: "Joe Bookreader",
favoriteGenres: [ ”mystery”, ”programming” ]
address: {
street: "123 Fake St. ",
city: "Faketon",
state: "MA",
zip: “12345”
}
}
Projection: Return only what you need
> db.patrons.find({ _id : “joe” }, {“_id”: 0, ”address”:1})
{
address: {
street: "123 Fake St. ",
city: "Faketon",
state: "MA",
zip: “12345”
}
}
> db.patrons.find({ _id : “joe” }, {“_id”: 0, “name”:1,
”address.state”:1})
{
name: "Joe Bookreader",
address: {
state: "MA”
}
}
17
Substructure Works Well With Code
> addr = db.patrons.find({_id :“joe”},{“_id”: 0,”address”:1})
{
address: {
street: "123 Fake St. ",
city: "Faketon",
state: "MA",
zip: “12345”
}
}
// Pass the whole Map to this function:
doSomethingWithOneAddress(addr);
// Somewhere else in the code is the actual function:
doSomethingWithOneAddress(Map addr)
{ // Look for state }
Remember: Document Shapes Can Vary
> db.patrons.insert({ _id : “bob”,
name: ”Bob Nobooks",
address: {
street: ”139 W45 St. ",
city: ”NY",
state: ”NY",
country: ”USA”
}
}
> db.patrons.find({},{“_id”: 1, ”address”:1})
{ _id: “joe”,
address: {
street: "123 Fake St. ",
city: "Faketon",
state: "MA",
zip: “12345”
}
}
{ _id: ”bob",
address: {
street: ”139 W45 St. ",
city: ”NY",
state: ”NY",
country: ”USA”
}
}
19
Substructure Amplifies Agility
> addr = db.patrons.find({_id :“bob”},{“_id”: 0,”address”:1})
{
address: {
street: ”139 W45 St. ",
city: ”NY",
state: ”NY",
country: ”USA”
}
}
// Pass the whole Map to this function:
doSomethingWithOneAddress(addr);
doSomethingWithOneAddress(Map addr)
{ // Look for state and optional country }
NO CHANGE
to queries
Only the single
implementation that
looks for country needs
to change
NO COMPILE-TIME
DEPENDENCIES
when passing Maps
20
The Advantage over Rectangles
resultSet = select street, state, city, country, …
Map addr = processIntoMap(resultSet);
// Pass the whole Map to this function:
doSomethingWithOneAddress(addr);
doSomethingWithOneAddress(Map addr)
{ // Look for state and optional country }
Queries must change
to pick up new columns
Compile-time
dependency to process
new columns to Map
21
Substructure Scales For Change
MongoDB
db.patrons.find({},
{”myAddress”:1,”yourAddress”:1,”brokerAddress”:1,
“momsAddress”:1, …})
Traditional SQL
resultSet = select mystreet, mystate, mycity, mycountry,
yourstreet, yourstate, yourcity, yourcountry, brokerstreet,
brokerstate, brokercity, brokercountry, momsstreet,
momsstate, momscity, momscountry, …
22
One-to-One Relationships
• “Belongs to” relationships are often embedded
• Holistic representation of entities with their
embedded attributes and relationships
• Great read performance
Most important:
• Keeps simple things simple
• Frees up time to tackle harder schema
design issues
23
Question:
What are a Patron’s Addresses?
A Patron and their Addresses
> db.patrons.find({ _id : “bob” })
{
_id: “bob",
name: “Bob Knowitall",
addresses: [
{street: "1 Vernon St.", city: "Newton", …},
{street: "52 Main St.", city: "Boston", …}
]
}
A Patron and their Addresses
> db.patrons.find({ _id : “bob” })
{
_id: “bob",
name: “Bob Knowitall",
addresses: [
{street: "1 Vernon St.", city: "Newton", …},
{street: "52 Main St.", city: "Boston", …}
]
}
> db.patrons.find({ _id : “joe” })
{
_id: "joe",
name: "Joe Bookreader",
address: { street: "123 Fake St. ", city: "Faketon", …}
}
26
Migration Options
• Migrate all documents when the schema changes.
• Migrate On-Demand
– As we pull up a patron’s document, we make the
change.
– Any patrons that never come into the library never get
updated.
• Leave it alone
– The code layer knows about both address and
addresses
27
Letting The Code Deal With Documents
Map d = collection.find(new BasicDBObject(”_id”,”bob”));
// Contract: Return either a List of addresses or a null
// if no addresses exist
// Try to get the new “version 2” shape:
List addrl = (List) d.get(”addresses”);
// If not there, try to get the old one:
if(addrl == null) {
Map oneAddr = (Map) d.get(”address”);
if(oneAddr != null) {
addrl = new List();
addrl.append(oneAddr);
}
}
// addrl either exists with 1 or more items or is null
28
Question:
Who is the publisher of this
book?
29
Book
• MongoDB: The Definitive Guide,
• By Kristina Chodorow and Mike Dirolf
• Published: 9/24/2010
• Pages: 216
• Language: English
• Publisher: O’Reilly Media, CA
Book with Embedded Publisher
> book = db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
authors: [ "Kristina Chodorow", "Mike Dirolf" ],
published_date: ISODate(”2010-09-24”),
pages: 216,
language: "English",
publisher: {
name: "O’Reilly Media",
founded: 1980,
locations: ["CA”, ”NY” ]
}
}
Don’t Forget the Substructure!
> book = db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
authors: [
{ first: "Kristina”, last: “Chodorow” },
{ first: ”Mike”, last: “Dirolf” }
],
published_date: ISODate(”2010-09-24”),
pages: 216,
language: "English",
publisher: {
name: "O’Reilly Media",
founded: 1980,
locations: ["CA”, ”NY” ]
}
}
32
One-To-Many Using Embedding
• Optimized for read performance of Books
• We accept data duplication
• An index on “publisher.name” provides:
– Efficient lookup of all books for given publisher name
– Efficient way to find all publisher names (distinct)
• Does not automatically mean there is no “master”
Publisher collection (from which data is copied when
creating a new Book)
Publishers as a Separate Entity
> publishers = db.publishers.find()
{
_id: “oreilly”,
name: "O’Reilly Media",
founded: 1980,
locations: ["CA”, ”NY” ]
}
{
_id: “penguin”,
name: ”Penguin”,
founded: 1983,
locations: [ ”IL” ]
}
Single Book with Linked Publisher
> book = db.books.find({ _id: “123” })
{
_id: “123”,
publisher_id: “oreilly”,
title: "MongoDB: The Definitive Guide",
…
}
> db.publishers.find({ _id : book.publisher_id })
{
_id: “oreilly”,
name: "O’Reilly Media",
founded: 1980,
locations: ["CA”, ”NY” ]
}
Multiple Books with Linked Publisher
db.books.find({ pages: {$gt:100}} ).forEach(function(book) {
// Do whatever you need with the book document, but
// in addition, capture publisher ID uniquely by
// using it as a key in an object (Map)
tmpm[book.publisher.name] = true;
});
uniqueIDs = Object.keys(tmpm); // extract ONLY keys
db.publishers.find({"_id": {"$in": uniqueIDs } });
Cartesian Product != Desired Structure
resultSet = “select B.name, B.publish_date, P.name, P.founded
from Books B, Publisher P
where P.name = B.publisher_name
and B.pages > 100”
B.Name B.publish_date P.name P.founded
More Jokes 2003 Random House 1843
Perl Tricks 1998 O’Reilly 1980
More Perl 2000 O’Reilly 1980
Starting Perl 1996 O’Reilly 1980
Flying Kites 1980 Random House 1843
Using Perl 2002 O’Reilly 1980
Bad Food 2011 Random House 1843
…And Tough To Use Without ORDER BY
resultSet = “select B.name, B.publish_date, P.name, P.founded
from Books B, Publisher P
where P.name = B.publisher_name
and B.pages > 100
order by P.name”;
B.Name B.publish_date P.name P.founded
Perl Tricks 1998 O’Reilly 1980
More Perl 2000 O’Reilly 1980
Using Perl 2002 O’Reilly 1980
Starting Perl 1996 O’Reilly 1980
Flying Kites 1980 Random House 1843
Bad Food 2011 Random House 1843
More Jokes 2003 Random House 1843
SQL Is About Disassembly
resultSet = “select B.name, B.publish_date, P.name, P.founded
from Books B, Publisher P
where P.name = B.publisher_name
and B.pages > 100
order by P.name”;
prev_name = null;
while(resultSet.next()) {
if(!resultSet.getString(“P.name”).equals(prevName)) {
// “next” publisher name found. Process material
// accumulated and reset for next items.
makeNewObjects(); //etc.
prev_name = resultSet.getString(“P.name”)
}
}
39
One-To-Many Using Linking
• Optimized for efficient management of mutable data
• Familiar way to organize basic entities
• Code is used to assemble fetched material into other
objects, not disassemble a single ResultSet
– More complicated queries may be easier to code and maintain
with assembly vs. disassembly
40
Question:
What are all the books a
publisher has published?
Publisher with Linked Books
> publisher = db.publishers.find({ _id : “oreilly” })
{
_id: “oreilly”,
name: "O’Reilly Media",
founded: 1980,
locations: [ "CA“, ”NY” ],
books: [“123”, “456”, “789”, “10112”, …]
}
> books = db.books.find({ _id: { $in : publisher.books } })
42
Question:
Who are the authors of a given
book?
Books with linked Authors
> book = db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
…
authors: [
{ _id: “X12”, first: "Kristina”, last: “Chodorow” },
{ _id: “Y45”, first: ”Mike”, last: “Dirolf” }
],
}
> a2 = book.authors.map(function(r) { return r._id; });
> authors = db.authors.find({ _id : { $in : a2}})
{_id:”X12”,name:{first:"Kristina”,last:”Chodorow”},hometown: …
}
{_id:“Y45”,name:{first:”Mike”,last:”Dirolf”}, hometown: … }
44
Question:
What are all the books an author
has written?
> db.authors.find({ _id : “X12” })
{
_id: ”X12",
name: { first: "Kristina”, last: “Chodorow” } ,
hometown: "Cincinnati",
books: [ {id: “123”, title : "MongoDB: The Definitive
Guide“ } ]
}
> db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
…
authors: [
{ _id: “X12”, first: "Kristina”, last: “Chodorow” },
{ _id: “Y45”, first: ”Mike”, last: “Dirolf” }
],
}
Double Link Books and Authors
> db.books.find({ _id : “123” })
{
authors: [
{ _id: “X12”, first: "Kristina”, last: “Chodorow” },
{ _id: “Y45”, first: ”Mike”, last: “Dirolf” }
],
}
> db.books.ensureIndex({“authors._id”: 1});
> db.books.find({ “authors._id” : “X12” }).explain();
{
"cursor" : "BtreeCursor authors.id_1",
…
"millis" : 0,
}
Another Approach: Index The Array
47
Embedding vs. Linking
• Embedding
– Terrific for read performance
• Webapp “front pages” and pre-aggregated material
• Complex structures
– Great for insert-only / immutable designs
– Inserts might be slower than linking
– Data integrity for not-belongs-to needs to be managed
• Linking
– Flexible
– Data integrity is built-in
– Work is done during reads
• But not necessarily more work than RDBMS
48
Question:
What are the personalized
attributes for each author?
> db.authors.find()
{
_id: ”X12",
name: { first: "Kristina”, last: “Chodorow” },
personalData: {
favoritePets: [ “bird”, “dog” ],
awards: [ {name: “Hugo”, when: 1983}, {name: “SSFX”,
when: 1992} ]
}
}
{
_id: ”Y45",
name: { first: ”Mike”, last: “Dirolf” } ,
personalData: {
dob: ISODate(“1970-04-05”)
}
}
Assign Dynamic Structure to a Known Name
> db.events.find()
{ type: ”click", ts: ISODate(“2015-03-03T12:34:56.789Z”,
data: { x: 123, y: 625, adId: “AE23A” } }
{ type: ”click", ts: ISODate(“2015-03-03T12:35:01.003Z”,
data: { x: 456, y: 611, adId: “FA213” } }
{ type: ”view", ts: ISODate(“2015-03-03T12:35:04.102Z”,
data: { scn: 2, reset: false, … } }
{ type: ”click", ts: ISODate(“2015-03-03T12:35:05.312Z”,
data: { x: 23, y: 32, adId: “BB512” } }
{ type: ”close", ts: ISODate(“2015-03-03T12:35:08.774Z”,
data: { snc: 2, logout: true, mostRecent: [ … ] } }
{ type: ”click", ts: ISODate(“2015-03-03T12:35:10.114Z”,
data: { x: 881, y: 913, adId: “F430” } }
Polymorphism: Worth an Extra Slide
51
Question:
What are all the books about
databases?
Categories as an Array
> db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
categories: [“MongoDB”, “Databases”, “Programming”]
}
> db.book.ensureIndex({categories:1});
> db.books.find({ categories: “Databases” })
Categories as a Path
> db.books.find({ _id : “123” })
{
_id: “123”,
title: "MongoDB: The Definitive Guide",
category: “Programming/Databases/MongoDB”
}
> db.books.find({ category: ^Programming/Databases/* })
Coming in v3.2: Document Validation
> db.createCollection("books", { "validator":
{ $and: [
{ "title": {$type: “string”} },
{ "publishDate": {$type: “date”} },
{ $or: [
{ "thumbnail": {$exists: False}},
{ "thumbnail": {$type: “binary”}}
]
}
]
}
});
Document Validation And Soft Schemas
> db.createCollection("books", { "validator":
{ $or: [
{ $and: [ { "v": 1},
{ "title": {$type: “string”} }
]
},
{ $and: [ { "v": 2},
{ "title": {$type: “string”} },
{ "publishDate": {$type: “date”} },
{ $or: [
{ "thumbnail": {$exists: False}},
{ "thumbnail": {$type: “binary”}}
]
}
]
}
]
});
56
Summary
• Physical design is different in MongoDB
– But basic data design principles stay the same
• Focus on how an application accesses/manipulates data
• Seek out and capture belongs-to 1:1 relationships
• Use substructure to better align to code objects
• Be polymorphic!
• Evolve the schema to meet requirements as they change
Questions & Answers
Thank You

Mais conteúdo relacionado

Mais procurados

MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema DesignAlex Litvinok
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDBrogerbodamer
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Javaantoinegirbal
 
Building your first app with mongo db
Building your first app with mongo dbBuilding your first app with mongo db
Building your first app with mongo dbMongoDB
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMike Friedman
 
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentosConceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentosMongoDB
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationMongoDB
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...MongoDB
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsMatias Cascallares
 
Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsMongoDB
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012hungarianhc
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDBMongoDB
 
User Data Management with MongoDB
User Data Management with MongoDB User Data Management with MongoDB
User Data Management with MongoDB MongoDB
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphSocialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphMongoDB
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...MongoDB
 
Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework MongoDB
 
Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLMongoDB
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real WorldMike Friedman
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaMongoDB
 

Mais procurados (20)

MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
Building your first app with mongo db
Building your first app with mongo dbBuilding your first app with mongo db
Building your first app with mongo db
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentosConceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
 
Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documents
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 
User Data Management with MongoDB
User Data Management with MongoDB User Data Management with MongoDB
User Data Management with MongoDB
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphSocialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 
Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework
 
Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQL
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
 

Destaque

Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...MongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...MongoDB
 
Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsMongoDB
 
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentMongoDB
 
Mongo db data-models guide
Mongo db data-models guideMongo db data-models guide
Mongo db data-models guideDeysi Gmarra
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialOSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialSteven Francia
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkBack to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkMongoDB
 
Beyond the Basics 1: Storage Engines
Beyond the Basics 1: Storage EnginesBeyond the Basics 1: Storage Engines
Beyond the Basics 1: Storage EnginesMongoDB
 
Advanced Schema Design Patterns
Advanced Schema Design PatternsAdvanced Schema Design Patterns
Advanced Schema Design PatternsMongoDB
 
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)MongoDB
 

Destaque (12)

Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to Basics
 
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
 
Mongo db data-models guide
Mongo db data-models guideMongo db data-models guide
Mongo db data-models guide
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialOSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB Tutorial
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkBack to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation Framework
 
MongoDB for Developers
MongoDB for DevelopersMongoDB for Developers
MongoDB for Developers
 
Beyond the Basics 1: Storage Engines
Beyond the Basics 1: Storage EnginesBeyond the Basics 1: Storage Engines
Beyond the Basics 1: Storage Engines
 
Advanced Schema Design Patterns
Advanced Schema Design PatternsAdvanced Schema Design Patterns
Advanced Schema Design Patterns
 
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
 

Semelhante a Thinking In Documents: Great Data Design Involves More Than Database

Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema design
Schema designSchema design
Schema designMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema design mongo_boston
Schema design mongo_bostonSchema design mongo_boston
Schema design mongo_bostonMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema & Design
Schema & DesignSchema & Design
Schema & DesignMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Jumpstart: Schema Design
Jumpstart: Schema DesignJumpstart: Schema Design
Jumpstart: Schema DesignMongoDB
 
Schema design
Schema designSchema design
Schema designchristkv
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsMongoDB
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema DesignMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...MongoDB
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDBMongoDB
 
Schema Design
Schema DesignSchema Design
Schema DesignMongoDB
 
Schema Design (Mongo Austin)
Schema Design (Mongo Austin)Schema Design (Mongo Austin)
Schema Design (Mongo Austin)MongoDB
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data ModelingDATAVERSITY
 

Semelhante a Thinking In Documents: Great Data Design Involves More Than Database (20)

Schema Design
Schema DesignSchema Design
Schema Design
 
Schema design
Schema designSchema design
Schema design
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Schema design mongo_boston
Schema design mongo_bostonSchema design mongo_boston
Schema design mongo_boston
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Schema & Design
Schema & DesignSchema & Design
Schema & Design
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Jumpstart: Schema Design
Jumpstart: Schema DesignJumpstart: Schema Design
Jumpstart: Schema Design
 
Schema design
Schema designSchema design
Schema design
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema Design
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Schema Design
Schema DesignSchema Design
Schema Design
 
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Schema Design
Schema DesignSchema Design
Schema Design
 
Schema Design (Mongo Austin)
Schema Design (Mongo Austin)Schema Design (Mongo Austin)
Schema Design (Mongo Austin)
 
MongoDB at GUL
MongoDB at GULMongoDB at GUL
MongoDB at GUL
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 

Mais de MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump StartMongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB
 

Mais de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Último

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Último (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

Thinking In Documents: Great Data Design Involves More Than Database

  • 1. Thinking In Documents Buzz Moschetti Enterprise Architect, MongoDB buzz.moschetti@mongodb.com @buzzmoschetti
  • 2. Before We Begin • This webinar is being recorded • Use The Chat Window for • Technical assistance • Q&A • MongoDB Team will answer quick questions in realtime • “Common” questions will be reviewed at the end of the webinar
  • 3. Theme #1: Great Data Design involves much more than the database • Easily understood structures • Harmonized with software • Acknowledging legacy issues
  • 4. Theme #2: Today’s solutions need to accommodate tomorrow’s needs • End of “Requirements Complete” • Ability to economically scale • Shorter solutions lifecycles
  • 6. RDBMS MongoDB Database Database Table Collection Index Index Row Document Column Field Join Embedding & Linking Terminology
  • 7. { _id: “123”, title: "MongoDB: The Definitive Guide", authors: [ { _id: "kchodorow", name: "Kristina Chodorow“ }, { _id: "mdirold", name: “Mike Dirolf“ } ], published_date: ISODate(”2010-09-24”), pages: 216, language: "English", thumbnail: BinData(0,"AREhMQ=="), publisher: { name: "O’Reilly Media", founded: 1980, locations: ["CA”, ”NY” ] } } What is a Document?
  • 8. // Java: maps DBObject query = new BasicDBObject(”publisher.founded”, 1980)); Map m = collection.findOne(query); Date pubDate = (Date)m.get(”published_date”); // java.util.Date // Javascript: objects m = collection.findOne({”publisher.founded” : 1980}); pubDate = m.published_date; // ISODate year = pubDate.getUTCFullYear(); # Python: dictionaries m = coll.find_one({”publisher.founded” : 1980 }); pubDate = m[”pubDate”].year # datetime.datetime Documents Map to Language Constructs
  • 9. 9 Traditional Data Design • Static, Uniform Scalar Data • Rectangles • Low-level, physical representation
  • 10. 10 Document Data Design • Flexible, Rich Shapes • Objects • Higher-level, business representation
  • 12. 12 Library Management Application • Patrons/Users • Books • Authors • Publishers
  • 13. 13 Question: What is a Patron’s Address?
  • 14. Patron + Address: Initial Attempt > db.patrons.find({ _id : “joe” }) { _id: "joe“, name: "Joe Bookreader”, favoriteGenres: [ ”mystery”, ”programming” ] } > db.addresses.find({ _id : “joe” }) { _id: "joe“, street: "123 Fake St.", city: "Faketon", state: "MA", zip: “12345” }
  • 15. Patron + Address: The MongoDB Way > db.patrons.find({ _id : “joe” }) { _id: "joe", name: "Joe Bookreader", favoriteGenres: [ ”mystery”, ”programming” ] address: { street: "123 Fake St. ", city: "Faketon", state: "MA", zip: “12345” } }
  • 16. Projection: Return only what you need > db.patrons.find({ _id : “joe” }, {“_id”: 0, ”address”:1}) { address: { street: "123 Fake St. ", city: "Faketon", state: "MA", zip: “12345” } } > db.patrons.find({ _id : “joe” }, {“_id”: 0, “name”:1, ”address.state”:1}) { name: "Joe Bookreader", address: { state: "MA” } }
  • 17. 17 Substructure Works Well With Code > addr = db.patrons.find({_id :“joe”},{“_id”: 0,”address”:1}) { address: { street: "123 Fake St. ", city: "Faketon", state: "MA", zip: “12345” } } // Pass the whole Map to this function: doSomethingWithOneAddress(addr); // Somewhere else in the code is the actual function: doSomethingWithOneAddress(Map addr) { // Look for state }
  • 18. Remember: Document Shapes Can Vary > db.patrons.insert({ _id : “bob”, name: ”Bob Nobooks", address: { street: ”139 W45 St. ", city: ”NY", state: ”NY", country: ”USA” } } > db.patrons.find({},{“_id”: 1, ”address”:1}) { _id: “joe”, address: { street: "123 Fake St. ", city: "Faketon", state: "MA", zip: “12345” } } { _id: ”bob", address: { street: ”139 W45 St. ", city: ”NY", state: ”NY", country: ”USA” } }
  • 19. 19 Substructure Amplifies Agility > addr = db.patrons.find({_id :“bob”},{“_id”: 0,”address”:1}) { address: { street: ”139 W45 St. ", city: ”NY", state: ”NY", country: ”USA” } } // Pass the whole Map to this function: doSomethingWithOneAddress(addr); doSomethingWithOneAddress(Map addr) { // Look for state and optional country } NO CHANGE to queries Only the single implementation that looks for country needs to change NO COMPILE-TIME DEPENDENCIES when passing Maps
  • 20. 20 The Advantage over Rectangles resultSet = select street, state, city, country, … Map addr = processIntoMap(resultSet); // Pass the whole Map to this function: doSomethingWithOneAddress(addr); doSomethingWithOneAddress(Map addr) { // Look for state and optional country } Queries must change to pick up new columns Compile-time dependency to process new columns to Map
  • 21. 21 Substructure Scales For Change MongoDB db.patrons.find({}, {”myAddress”:1,”yourAddress”:1,”brokerAddress”:1, “momsAddress”:1, …}) Traditional SQL resultSet = select mystreet, mystate, mycity, mycountry, yourstreet, yourstate, yourcity, yourcountry, brokerstreet, brokerstate, brokercity, brokercountry, momsstreet, momsstate, momscity, momscountry, …
  • 22. 22 One-to-One Relationships • “Belongs to” relationships are often embedded • Holistic representation of entities with their embedded attributes and relationships • Great read performance Most important: • Keeps simple things simple • Frees up time to tackle harder schema design issues
  • 23. 23 Question: What are a Patron’s Addresses?
  • 24. A Patron and their Addresses > db.patrons.find({ _id : “bob” }) { _id: “bob", name: “Bob Knowitall", addresses: [ {street: "1 Vernon St.", city: "Newton", …}, {street: "52 Main St.", city: "Boston", …} ] }
  • 25. A Patron and their Addresses > db.patrons.find({ _id : “bob” }) { _id: “bob", name: “Bob Knowitall", addresses: [ {street: "1 Vernon St.", city: "Newton", …}, {street: "52 Main St.", city: "Boston", …} ] } > db.patrons.find({ _id : “joe” }) { _id: "joe", name: "Joe Bookreader", address: { street: "123 Fake St. ", city: "Faketon", …} }
  • 26. 26 Migration Options • Migrate all documents when the schema changes. • Migrate On-Demand – As we pull up a patron’s document, we make the change. – Any patrons that never come into the library never get updated. • Leave it alone – The code layer knows about both address and addresses
  • 27. 27 Letting The Code Deal With Documents Map d = collection.find(new BasicDBObject(”_id”,”bob”)); // Contract: Return either a List of addresses or a null // if no addresses exist // Try to get the new “version 2” shape: List addrl = (List) d.get(”addresses”); // If not there, try to get the old one: if(addrl == null) { Map oneAddr = (Map) d.get(”address”); if(oneAddr != null) { addrl = new List(); addrl.append(oneAddr); } } // addrl either exists with 1 or more items or is null
  • 28. 28 Question: Who is the publisher of this book?
  • 29. 29 Book • MongoDB: The Definitive Guide, • By Kristina Chodorow and Mike Dirolf • Published: 9/24/2010 • Pages: 216 • Language: English • Publisher: O’Reilly Media, CA
  • 30. Book with Embedded Publisher > book = db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", authors: [ "Kristina Chodorow", "Mike Dirolf" ], published_date: ISODate(”2010-09-24”), pages: 216, language: "English", publisher: { name: "O’Reilly Media", founded: 1980, locations: ["CA”, ”NY” ] } }
  • 31. Don’t Forget the Substructure! > book = db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", authors: [ { first: "Kristina”, last: “Chodorow” }, { first: ”Mike”, last: “Dirolf” } ], published_date: ISODate(”2010-09-24”), pages: 216, language: "English", publisher: { name: "O’Reilly Media", founded: 1980, locations: ["CA”, ”NY” ] } }
  • 32. 32 One-To-Many Using Embedding • Optimized for read performance of Books • We accept data duplication • An index on “publisher.name” provides: – Efficient lookup of all books for given publisher name – Efficient way to find all publisher names (distinct) • Does not automatically mean there is no “master” Publisher collection (from which data is copied when creating a new Book)
  • 33. Publishers as a Separate Entity > publishers = db.publishers.find() { _id: “oreilly”, name: "O’Reilly Media", founded: 1980, locations: ["CA”, ”NY” ] } { _id: “penguin”, name: ”Penguin”, founded: 1983, locations: [ ”IL” ] }
  • 34. Single Book with Linked Publisher > book = db.books.find({ _id: “123” }) { _id: “123”, publisher_id: “oreilly”, title: "MongoDB: The Definitive Guide", … } > db.publishers.find({ _id : book.publisher_id }) { _id: “oreilly”, name: "O’Reilly Media", founded: 1980, locations: ["CA”, ”NY” ] }
  • 35. Multiple Books with Linked Publisher db.books.find({ pages: {$gt:100}} ).forEach(function(book) { // Do whatever you need with the book document, but // in addition, capture publisher ID uniquely by // using it as a key in an object (Map) tmpm[book.publisher.name] = true; }); uniqueIDs = Object.keys(tmpm); // extract ONLY keys db.publishers.find({"_id": {"$in": uniqueIDs } });
  • 36. Cartesian Product != Desired Structure resultSet = “select B.name, B.publish_date, P.name, P.founded from Books B, Publisher P where P.name = B.publisher_name and B.pages > 100” B.Name B.publish_date P.name P.founded More Jokes 2003 Random House 1843 Perl Tricks 1998 O’Reilly 1980 More Perl 2000 O’Reilly 1980 Starting Perl 1996 O’Reilly 1980 Flying Kites 1980 Random House 1843 Using Perl 2002 O’Reilly 1980 Bad Food 2011 Random House 1843
  • 37. …And Tough To Use Without ORDER BY resultSet = “select B.name, B.publish_date, P.name, P.founded from Books B, Publisher P where P.name = B.publisher_name and B.pages > 100 order by P.name”; B.Name B.publish_date P.name P.founded Perl Tricks 1998 O’Reilly 1980 More Perl 2000 O’Reilly 1980 Using Perl 2002 O’Reilly 1980 Starting Perl 1996 O’Reilly 1980 Flying Kites 1980 Random House 1843 Bad Food 2011 Random House 1843 More Jokes 2003 Random House 1843
  • 38. SQL Is About Disassembly resultSet = “select B.name, B.publish_date, P.name, P.founded from Books B, Publisher P where P.name = B.publisher_name and B.pages > 100 order by P.name”; prev_name = null; while(resultSet.next()) { if(!resultSet.getString(“P.name”).equals(prevName)) { // “next” publisher name found. Process material // accumulated and reset for next items. makeNewObjects(); //etc. prev_name = resultSet.getString(“P.name”) } }
  • 39. 39 One-To-Many Using Linking • Optimized for efficient management of mutable data • Familiar way to organize basic entities • Code is used to assemble fetched material into other objects, not disassemble a single ResultSet – More complicated queries may be easier to code and maintain with assembly vs. disassembly
  • 40. 40 Question: What are all the books a publisher has published?
  • 41. Publisher with Linked Books > publisher = db.publishers.find({ _id : “oreilly” }) { _id: “oreilly”, name: "O’Reilly Media", founded: 1980, locations: [ "CA“, ”NY” ], books: [“123”, “456”, “789”, “10112”, …] } > books = db.books.find({ _id: { $in : publisher.books } })
  • 42. 42 Question: Who are the authors of a given book?
  • 43. Books with linked Authors > book = db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", … authors: [ { _id: “X12”, first: "Kristina”, last: “Chodorow” }, { _id: “Y45”, first: ”Mike”, last: “Dirolf” } ], } > a2 = book.authors.map(function(r) { return r._id; }); > authors = db.authors.find({ _id : { $in : a2}}) {_id:”X12”,name:{first:"Kristina”,last:”Chodorow”},hometown: … } {_id:“Y45”,name:{first:”Mike”,last:”Dirolf”}, hometown: … }
  • 44. 44 Question: What are all the books an author has written?
  • 45. > db.authors.find({ _id : “X12” }) { _id: ”X12", name: { first: "Kristina”, last: “Chodorow” } , hometown: "Cincinnati", books: [ {id: “123”, title : "MongoDB: The Definitive Guide“ } ] } > db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", … authors: [ { _id: “X12”, first: "Kristina”, last: “Chodorow” }, { _id: “Y45”, first: ”Mike”, last: “Dirolf” } ], } Double Link Books and Authors
  • 46. > db.books.find({ _id : “123” }) { authors: [ { _id: “X12”, first: "Kristina”, last: “Chodorow” }, { _id: “Y45”, first: ”Mike”, last: “Dirolf” } ], } > db.books.ensureIndex({“authors._id”: 1}); > db.books.find({ “authors._id” : “X12” }).explain(); { "cursor" : "BtreeCursor authors.id_1", … "millis" : 0, } Another Approach: Index The Array
  • 47. 47 Embedding vs. Linking • Embedding – Terrific for read performance • Webapp “front pages” and pre-aggregated material • Complex structures – Great for insert-only / immutable designs – Inserts might be slower than linking – Data integrity for not-belongs-to needs to be managed • Linking – Flexible – Data integrity is built-in – Work is done during reads • But not necessarily more work than RDBMS
  • 48. 48 Question: What are the personalized attributes for each author?
  • 49. > db.authors.find() { _id: ”X12", name: { first: "Kristina”, last: “Chodorow” }, personalData: { favoritePets: [ “bird”, “dog” ], awards: [ {name: “Hugo”, when: 1983}, {name: “SSFX”, when: 1992} ] } } { _id: ”Y45", name: { first: ”Mike”, last: “Dirolf” } , personalData: { dob: ISODate(“1970-04-05”) } } Assign Dynamic Structure to a Known Name
  • 50. > db.events.find() { type: ”click", ts: ISODate(“2015-03-03T12:34:56.789Z”, data: { x: 123, y: 625, adId: “AE23A” } } { type: ”click", ts: ISODate(“2015-03-03T12:35:01.003Z”, data: { x: 456, y: 611, adId: “FA213” } } { type: ”view", ts: ISODate(“2015-03-03T12:35:04.102Z”, data: { scn: 2, reset: false, … } } { type: ”click", ts: ISODate(“2015-03-03T12:35:05.312Z”, data: { x: 23, y: 32, adId: “BB512” } } { type: ”close", ts: ISODate(“2015-03-03T12:35:08.774Z”, data: { snc: 2, logout: true, mostRecent: [ … ] } } { type: ”click", ts: ISODate(“2015-03-03T12:35:10.114Z”, data: { x: 881, y: 913, adId: “F430” } } Polymorphism: Worth an Extra Slide
  • 51. 51 Question: What are all the books about databases?
  • 52. Categories as an Array > db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", categories: [“MongoDB”, “Databases”, “Programming”] } > db.book.ensureIndex({categories:1}); > db.books.find({ categories: “Databases” })
  • 53. Categories as a Path > db.books.find({ _id : “123” }) { _id: “123”, title: "MongoDB: The Definitive Guide", category: “Programming/Databases/MongoDB” } > db.books.find({ category: ^Programming/Databases/* })
  • 54. Coming in v3.2: Document Validation > db.createCollection("books", { "validator": { $and: [ { "title": {$type: “string”} }, { "publishDate": {$type: “date”} }, { $or: [ { "thumbnail": {$exists: False}}, { "thumbnail": {$type: “binary”}} ] } ] } });
  • 55. Document Validation And Soft Schemas > db.createCollection("books", { "validator": { $or: [ { $and: [ { "v": 1}, { "title": {$type: “string”} } ] }, { $and: [ { "v": 2}, { "title": {$type: “string”} }, { "publishDate": {$type: “date”} }, { $or: [ { "thumbnail": {$exists: False}}, { "thumbnail": {$type: “binary”}} ] } ] } ] });
  • 56. 56 Summary • Physical design is different in MongoDB – But basic data design principles stay the same • Focus on how an application accesses/manipulates data • Seek out and capture belongs-to 1:1 relationships • Use substructure to better align to code objects • Be polymorphic! • Evolve the schema to meet requirements as they change

Notas do Editor

  1. HELLO! This is Buzz Moschetti at MongoDB, and welcome to today’s webinar entitled “Thinking in Documents”, part of our Back To Basics series. If your travel plans today do not include exploring the document model in MongoDB then please exit the aircraft immediately and see an agent at the gate Otherwise – WELCOME ABOARD for about the next hour.
  2. Let’s talk about some the terms. JOINS: RDBMS uses Join to stich together fundamentally simple things into larger, more complex data. MongoDB uses embedding of data within data and linking to produce the same result
  3. There are three themes that are important to grasp when Thinking In Documents in MongoDB and these will be reinforced throughout the presentation. First, great schema design…. I’ll repeat it: great… This is not new or something revolutionary to MongoDB. It is something we have been doing all along in the construction of solutions. Sometimes well, sometimes not. It’s just that the data structures and APIs used by MongoDB make it much easier to satisfy the first two bullet points. Particularly for an up-stack software engineer kind of person like myself, the ease and power of well-harmonizing your persistence with your code – java, javascript, perl, python – is a vital part of ensuring your overall information architecture is robust. Part of the exercise also involves candidly addressing legacy RDBMS issues that we see over and over again after 40 years, like schema explosion and field overloading and flattening Boils down to success = “schema” + code
  4. Potentially very provocative. In the old days, we had long requirements cycles and one or both of the following things happened: Requirements changed midstream, invalidating a lot of schema design already performed especially for certain 1:1 entity relationships High quality problem: The solution was asked to scale well beyond the original goals Increasingly, it is no longer acceptable to have a 6 or 12 or 18 month requirements phase to build a system that lasts 10 years or more. You want to get the initial information architecture done in a couple of weeks, expand upon it incrementally, and build a system that doesn’t have to live 10 years to “justify its development time.”
  5. Because MongoDB is impedance matched to the software around it, you have a great deal of design flexibility and even innovation in the way you construct the overall solution. We’ll explore some of those best practices today that will really put you on the road to Thinking In Documents
  6. Let’s talk about some the terms. JOINS: RDBMS uses Join to stich together fundamentally simple things into larger, more complex data. MongoDB uses embedding of data within data and linking to produce the same result
  7. A document is not a PDF or a MS word artifact. A document a term for a rich shape. Structures of structures of lists of structures that ultimately at the leaves have familiar scalars like int, double, datetimes, and string. In this example we see also that we’re carrying a thumbnail photo in a binary byte array type; that’s natively supported as well. This is different than the traditional row-column approach used in RDBMS. Another important difference is that In MongoDB, it is not required for every document in a collection to be the same shape; shapes can VARY With the upcoming release of 3.2, we will be supporting documentation validation so in those designs where certain fields and their types are absolutely mandatory, we’ll be able to enforce that at the DB engine level similar to – but not exactly like – traditional schemas. Truth is in most non-trivial systems, even with RDBMS and stored procs, etc. plenty of validation and logic is being handled outside the database.. Now here is something very important: For the purposes of the webinar, we will be seeing this “to-string” representation of a document as it is emitted from the MongoDB CLI. This is easy to read and gets the structural design points across nicely. But make no mistake: you want most of your actual software interaction with MongoDB (and frankly any DB) to be via high fidelity types, not a big string with whitespaces and CR and quotes and whatnot.
  8. Drivers in each language represent documents in a language-native form most appropriate for that language. Java has maps, python has dictionaries. You deal with actual objects like Dates, not strings that must be constructed or parsed. Another important note: We’ll be using query functionality to kill 2 birds with one stone: To show the shape of the document To show just a bit of the MongoDB query language itself including dotpath notation to “dig into” substructures Note also that in MongoDB, documents go into collections in the same shape they come out so we won’t focus on insert. This is a very different design paradigm from RDBMS, where, for example, the read-side of an operation implemented as an 8 way join is very different than the set of insert statements (some of them in a loop) required for the write side.
  9. Let’s get back to data design. … Traditional data design is characterized by some of the points above, and this is largely because the design goals and constraints of legacy RDBMS engines heavily influence the data being put into them. These platforms were designed when CPUs were slow and memory was VERY expensive. Perhaps more interesting is that the languages of the time – COBOL, FORTRAN, APL, PASCAL, C – were very compile time oriented and very rectangular in their expression of data structures. One could say rigid schema combined with these languages was in fact well-harmonized. Overall, the platform is VERY focused on the physical representation of data. For example, although most have been conflated, the legacy types of char, varchar, text, CLOB etc. to represent a string suggest a strong coupling to byte-wise storage concerns.
  10. Documents, on the other hand, are more like business entities. You’ll want to think of your data moving in and out as objects. And the types and features of Document APIs are designed to be well-harmonized with today’s programming languages – Java, C#, python, node.js, Scala , C++ -- languages that are not nearly as compile-time oriented and offer great capabilities to dynamically manipulate data and perform reflection/introspection upon it.
  11. So what better way to show this than diving right into a problem?
  12. Today we’ll explore data structures and schema for a library management application Good example because in general most of you have some familiarity with the entities involved and we can explore some 1:1, 1:n and other design elements
  13. To make things a little more interesting, we’ll capture our emerging requirements in the form of questions the application needs to ask the database. This is useful because, again, it helps us keep our eye on the software layer above the database Imagine a patron walks up to the counter and presents his/her library card to check out some books. The first thing a librarian might want to do is confirm the patron’s address so as to have a place to send the library police when the book isn’t returned in a timely manner.
  14. This might be the very first cut at such a thing, with 2 collections, patrons and addresses. Both share a common key space on the _id unique ID field. To get name and address will require 2 queries. Very important: You notice here that a list of favorite genres has been set up. It is a LIST of strings. Not a semicolon or comma delimited string. Each element of that list is completely addressable, queryable, and updatable via dotpath notation. As is the entire list. And should we require it, it is indexable. But let’s not get too far ahead. Can we do better?
  15. I think we can: embed the address substructure into the patron document. Only 1 query is necessary. You notice here that we treated address like an Object. We did not “flatten” everything out into addr_street, addr_city, addr_state, etc. We’ll come back to that again in just a few slides and see the power it provides. Already, with this simple example, two important aspects of Thinking In Documents are hilighted: arrays and substructures.
  16. A common concern that pops up at this point is that every query will act like “SELECT *” and drag back potentially a LOT of data. In MongoDB you can control that with projection as we see here, where fields can be explicitly included or excluded. This operation is of course processed server side and is efficient. Note that we can both pick up an entire substructure as a unit OR JUST specific subfields using “dot notation”. Very powerful.
  17. Before I mentioned we’d see more about the power of substructure. Substructure is the concept that allows your schema to really well-harmonize with software. By being able to pull out the entire address structure, you can pass it to a function that does something interesting with no matter what fields are or are not set. And what’s really great is that these substructures are generic Maps or dictionaries – NO COMPILE TIME dependencies!
  18. If your Thinking in Documents, then remember that Document Shapes can vary. Apols for the small font. But here, we are inserting a new document where address contains an additional field “country” (and, if you’re watching closely, does NOT have the zipcode field!) When do a find and ask for the address field, two slightly different shapes emerge.
  19. But more importantly, only one place “needs” to change: the place where the new “country” field is actually consumed. Neither the query nor the intermediate parts of the call stack change at all – the new country field simply flows through!
  20. Assuming you’re not in a “select *” environment which has it’s own huge set of issues, this is the traditional approach to the same problem. For brevity I am leaving out the entire issue of ALTER TABLE and schema migration scripts which may be avoided in MongoDB. The focus here is agilty and accuracy of Day 2 mods needed and how many places you have to make them. Here, Every SQL statement that pulled out city, state, and zip has to be assessed in the context of doSomethingWithOneAddress(). In others words, if the call to doSomethingWithOneAddress() exists in code – the call NOT the one implementation -- then BOTH the SQL statement and the thing that converts it into a useful object (located hopefully nearby) have to be modified. This potentially is a large undertaking!
  21. The problem is magnified by the number of addresses that you may be pulling out. In SQL and rectangles, you have to track down everything that looks like it is part of an address and ALTER TABLE and add columns to the select statements. In MongoDB and Documents, the additional material is automatically collected and flowed downstream with no DDL or compile time entanglements. We’ll see in a moment how Lists in Documents make this easier still!
  22. Let’s summarize one-to-one relationships. Read performance – especially for complex shapes of documents that otherwise would entail multiway JOINs -- is optimized because we only need a single query and a single disk/memory hit.. MongoDB is especially useful in dealing with 1:1 belongs-to relationships Not every non-scalar datum is going to force you to create a new table, a foreign key, and key management. It keeps simple things simple.
  23. Business Requirements Change! People may have more than one address. And: we acknowledge that the legacy practice of assuming some small number of instances and flattening out addresses into address1 and address2 is bound to bump up against a situation where someone has 3 addresses. We’ve seen where that leads traditional schema design. We don’t want to repeat it.
  24. Now, just model addresses as an array. That was easy. No need to create a new table, set up foreign keys, do key management, etc. We combine the power of arrays with substructures. At times it takes longer to describe the change than it does to implement it and have it available as part of the information architecture including querying and indexing. And again, these rich structures are presented in the client side driver as Lists, Maps, dictionaries, arrays and other high-fidelity types.
  25. Now suppose this design change occurred on Day 2, after the system was placed into production. What about the old documents that had address, not addresses? There are 2 aspects to this issue. The MongoDB paradigm is that the code layer just above the DB is responsible for managing these types of things. The same code that is responsible for the higher-level business validation and verification is also responsible for selectively using (both on a read and write basis) the address or addresses field. There are several migration strategies that one could employ in conjunction with functionality at the code layer. Remember, Thinking In Documents means thinking about documents with varying shapes.
  26. Migrate on release: If address exists, write into new array of size 1 of new fields addresses and remove address field.
  27. When we say “let the code deal with it” we mean something like this. The Data Access Layer code in cooperation with the Document model significantly eases Day 2 information architecture change. And again, this is an important aspect of Thinking In Documents.
  28. Moving on, let’s look at another relationship in our emerging information architecture: publisher and books.
  29. Shameless plug! Note that a book may have multiple authors….
  30. Here’s a first cut at the design. Here, the 1:! Belongs-to relationship between book and publisher is not nearly as strong as patron to address But for the moment, let’s choose to duplicate publisher in every book that the publisher has published. Data duplication is OK because the publisher is largely immutable.
  31. Here’s an even better one: making the author name more granular by making it a substructure with separate first and last name elements. A good rule of thumb is to try to eliminate embedded whitespace or punctuation in a field by breaking it down into substructure.
  32. This design will permit very high speed display of relevant book information. And we can still quickly look up all books for a given publisher.
  33. Suppose publisher info is not so static. Maybe we want to take a more traditional route and separate publisher information out into it’s own collection. We need to assign _ids and we’ll use simplified examples here. Note that in MongoDB each document needs a unique _id but it’s not important for today’s talk to get into the advanced topic of _id construction If you don’t supply one, one will be created automatically. And here’s a teaser: _id does not have to be a string or number or scalar: it can be a multi-field substructure! Note that the belongs-to 1:1 relationship of locations carries over nicely without fuss.
  34. It now takes 2 queries to pull the information. Now this isn’t the end of the world. It’s effectively no more code work than a JOIN. Instead of decomposing a resultset or passing the result into an ORM, your code layer deals directly with the database.
  35. If we want to get more than one book, no problem. Get the books and as you’re processing the book data, capture the publisher ID. We store it in a map to remove duplicate IDs Then we turn around and do an efficient lookup by primary key into the publishers collection. This works well regardless of whether the list is 1 long or 10,000. This is effectively the multi value JOIN. And of course the approach applies to linking any number of collections, not just the 2 we see here. In MongoDB, the application assembles material from multiple queries. Before the chat window lights up with all sorts of questions and rage, let’s do a quick compare and contrast to SQL.
  36. This example should be straightforward to most of you. As you know, the basic behavior of JOIN has some subtle issues: The cartesian product in the ResultSet is a giant rectangle containing repeating column values; you have to do something to change that into a form well-digestable by your application. Depending on the amount of JOINed columns and the cardinality, you could be redundantly dragging LOTS of data across the network. And on top of it all, it’s hard to deal with Giant Rectangle efficiently because the JOINed data is jumping around.
  37. This leads us to run things through ORDER BY so that we can now more easily deal with the Giant Rectangle. What does this do to performance? What if it’s more than a 2 way JOIN? 4 or 8 way?
  38. In the end, for anything except the most trivial of JOINs, the amount of work required to unwind or disassemble the Giant Rectangle is largely the same amount of code as It takes for MongoDB to assemble material. For sophisticated queries to complex shapes, it could be argued that assembly is both easier to write AND maintain Day 2.
  39. This design will permit very high speed display of relevant book information. And we can still quickly look up all books for a given publisher.
  40. We have already seen a way to do this : by performing a find() on the Books collection with a particular publisher name OR publisher ID. But is there another way?
  41. As much as arrays are very useful in MongoDB, beware of the temptation to treat them as “rows.” Arrays should be “slow-growing” and not without a reasonable bound. For example, you wouldn’t carry system of record customer transactions as a array inside the customer. You MIGHT, however, for the purposes of speed at scale, duplicate the last 3 transactions as an array in the customer record – but that array is not growing without bound. From an underlying technology basis, this is less of an issue now with the WiredTiger storage engine available in 3.0 but you should still be mindful of it.
  42. As our schema is evolving, we’re beginning to see that an increasing number of questions can be efficiently answered by existing set of entities and relationships. This holds for authors; recall we set up the substructure of first and last names. But suppose we want more detail on an author?
  43. Let’s go ahead and create the Authors collection and link to it with a Author ID. Yes, we are using some fancier code here to extract the author IDs but in the end, it is still only 2 queries. The fancy code here is using a map() operation to extract just the author IDs which will be passed along to the $in operator The authors documents contain all sorts of information about each author. We have left the first and last names in the books document for the purposes of speed But we could get rid of them if we wanted. It is a choice of integrity vs. speed of retrieval.
  44. Inevitably, we turn the question around and start to expose ourselves to the MANY-TO-MANY problem.
  45. Here’s one way to do it: Acknowledging that most authors are not steven king or danielle steele and have something of upper bound on the books they’ve written, we can doubly link the books and authors collection. In general the data is static so referential integrity is not as much as an issue as performance. Again, we’ve kept title in the structure within the books field for performance purposes (to keep it to a single query) when looking up basic info about an author. But if so desired, we could just have books be an array of book IDs and use a 2-query approach as we’ve seen in prior slides. Note this is different than publishers having an array of books because the upper bound for author-to-books is much less than publisher-to-books.
  46. Remember: all fields including those inside structures inside arrays are indexable. We saw an example of this earlier with indexing on publisher.name
  47. Complex structures like arrays of coordinate pairs, deep nested data, etc. With immutable designs, sometimes the safest / easiest route is to dereference the data. Note that with the emergence of deduping storage arrays, this is increasingly becoming a practical and exciting solution!
  48. Suppose the library wants to add value by having book clubs enhance the authors information with bespoke information. There are at least 3 challenges here: 1. the book club is operating semi-independently from the main system designers Clearly, we don’t know early on what the book club is going to add Each author may have a different set of information, created by a different member of the book club.
  49. This is a very, very exciting part of MongoDB. No need to come up with userDefined column 1, column 2, etc. We see here that Kristina and Mike have very different substructures inside the personalData field. We call this polymorphism: the variation of shape from document-to-document within the same collection. The library application logic only is looking for a field called “personalData”; actions will be taken dynamically based on the shape and types in the substructure! For example, It is a very straightforward exercise to recursively “walk” the structure and construct a panel in a GUI – especially if you are using AngularJS and the MEAN stack (MongoDB / Express / Angular / Node.js ) No need to use XML or blobs or serialized objects. It’s all native MongoDB -- and documents are represented in the form most easily natively manipulated by the language Every field is queryable and if so desired, indexable! Documents that do not contain fields in a query predicate are simply treated as unset.
  50. Polymorphism is such an important aspect of Thinking In Documents that it deserves another slide.. Here’s an events collection. We’ve taken out _id for some extra space. Type and ts and data are the well-known fields, and there is probably an index on type and ts. But the data field contents are specialized for each type. No need for complex tables or blobs or XML. And very easily extensible to new types we may need to add on day 2. This model extends to products, transactions, actors in a data design.. If you think about your data in terms of entities, you’ll discover that you probably only need a handful. That plus polymorphism within the entity gets you a long way. Because of this design approach, rarely will a MongoDB database have 100s of collections
  51. This is an example of faceted search or tagging in general.
  52. We can begin simply by implementing Categories as an array We probably will only have a few and they don’t change very often and have a natural upward bound. An index on categories will allow rapid retrieval. Again, a very appropriate use of belongs-to 1:1
  53. If we want a little more hierarchy, we can use regex operations. The category field is indexed as before, but now as a string Uses an index because of the anchored regular expression. There is a downside: when a category hierarchy gets changed, all documents will need to be re-categorized.
  54. A little techno-trailer for you: Document Validation. Coming in v3.2, Document Validation “inverts” the use of existing MongoDB query language. Documents being inserted or updated will be assessed against a validator if it exists. There are a number of special features including “strictness on update” that are beyond the scope of today’s presentation but the good news is that it is coming!
  55. We’ll close with something really cool – document validation that adapts to change over time. Assuming you “soft version” your documents by including a logical version ID ( in this case, a simple integer in field v) , you can maintain multiple different shapes of documents in one collection, each of them validation enforced to the version rules appropriate at the time. And again, because it is at the DB engine level, enforcement is guaranteed through all drivers. SUPER POWERFUL!
  56. On behalf of all of us at MongoDB , thank you for attending this webinar! I hope what you saw and heard today gave you some insight and clues into what you might face in your own data design efforts. Remember you can always reach out to us at MongoDB for guidance. With that, code well and be well.