SlideShare a Scribd company logo
1 of 56
From Tables to Documents—
Changing Your Database Mindset
Lauren Schaefer, Developer Advocate, MongoDB
Parks and Recreation, Season 6, Episode 14 @Lauren_Schaefer
@Lauren_Schaefer
@Lauren_Schaefer
@Lauren_Schaefer
Parks and Recreation, Season 6, Episode 14 @Lauren_Schaefer
@Lauren_Schaefer
Developer Advocate, MongoDB
@Lauren_Schaefer
From Tables to
Documents
Changing Your Database Mindset
@Lauren_Schaefer
Themental
journey from
tables to
documents
1. Model data in tables and documents
2. Map terms & concepts from tables to documents
3. Q&A
@Lauren_Schaefer
Themental
journey from
tables to
documents
1. Model data in tables and documents
2. Map terms & concepts from tables to documents
3. Q&A
@Lauren_Schaefer
Let’s talk
about
documents
@Lauren_Schaefer
Let’s talk
about
documents
@Lauren_Schaefer
Let’s talk
about
documents
{
}
@Lauren_Schaefer
Let’s talk
about
documents
{
field: value,
field: value,
field: value
}
@Lauren_Schaefer
@Lauren_Schaefer
ID first_name last_name cell city
1 Leslie Yepp 8125552344 Pawnee
Users
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee"
}
ID first_name last_name cell city
1 Leslie Yepp 8125552344 Pawnee
UsersUsers
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee"
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": "8125559347",
"city": "Pawnee"
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": "8125559347",
"city": "Pawnee"
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": "8125559347",
"city": "Pawnee",
"hobbies": [
"woodworking",
"fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": "CEO, Kinda Good Building
Company",
"yearStarted": 2014
}
]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": "8125559347",
"city": "Pawnee",
"hobbies": [
"woodworking",
"fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": "CEO, Kinda Good Building
Company",
"yearStarted": 2014
}
]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": "8125559347",
"city": "Pawnee",
"hobbies": [
"woodworking",
"fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": "CEO, Kinda Good Building
Company",
"yearStarted": 2014
}
]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude school
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL Pawnee
Elementar
y
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude school
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL Pawnee
Elementar
y
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ]
}
@Lauren_Schaefer
{
"_id": 1,
"first_name": "Leslie",
"last_name": "Yepp",
"cell": "8125552344",
"city": "Pawnee",
"location": [ -86.536632, 39.170344 ],
"hobbies": [
"scrapbooking",
"eating waffles",
"working”
],
"jobHistory": [
{
"title": "Deputy Director",
"yearStarted": 2004
},
{
"title": "City Councillor",
"yearStarted": 2012
},
{
"title": "Director, National Parks
Service, Midwest Branch",
"yearStarted": 2014
}
]
}
ID first_name last_name cell city latitude longitude school
1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL
2 Ron Swandaughte
r
8125559347 Pawnee NULL NULL NULL
3 Lauren Burhug NULL Pawnee NULL NULL Pawnee
Elementar
y
UsersUsers
ID user_id hobby
10 1 scrapbooking
11 1 eating waffles
12 1 working
13 2 woodworking
14 2 fishing
15 3 soccer
Hobbies
ID user_id job_title year_started
20 1 Deputy Directory 2004
21 1 City Councilor 2012
22 1 Director, National
Parks Service,
Midwest Branch
2014
23 2 Director 2002
24 2 CEO, Kinda Good
Building Company
2014
JobHistory
{
"_id": 1,
"first_name": "Ron",
"last_name": "Swandaughter",
"cell": ”8125559347",
"city": "Pawnee",
"hobbies": [
”woodworking",
”fishing"
],
"jobHistory": [
{
"title": "Director",
"yearStarted": 2002
},
{
"title": ”CEO, Kinda Good Building Company",
"yearStarted": 2014
}
]
}
{
"_id": 3,
"first_name": "Lauren",
"last_name": "Burhug",
"city": "Pawnee",
"hobbies": [ "soccer" ],
"school": "Pawnee Elementary"
}
@Lauren_Schaefer
FlexibleSchema
@Lauren_Schaefer
FlexibleSchema
Don’t panic!
Use schema validation.
@Lauren_Schaefer
Themental
journey from
tables to
documents
1. Model data in tables and documents
2. Map terms & concepts from tables to documents
3. Q&A
@Lauren_Schaefer
Row Document
{
...
a: “b”
...
}
ID a ...
1 b ...
2 ... ...
3 ... ...
@Lauren_Schaefer
Row(s) Document
{
...
a: “b”
...
}
ID a ...
1 b ...
2 ... ...
3 ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
@Lauren_Schaefer
Column Field
ID a ...
1 b ...
2 c ...
3 ... ...
{
...
a: “b”
...
}
{
...
a: “c”
...
}
@Lauren_Schaefer
Table Collection
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
{
...
}
{
...
}
@Lauren_Schaefer
Database Database
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
@Lauren_Schaefer
Index Index
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
@Lauren_Schaefer
View View
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
{
...
}
{
...
}
@Lauren_Schaefer
Join Embedding
{
...
a: “b”,
...
c: {
d: “e”
...
},
...
}
ID a ...
1 b ...
2 ... ...
3 ... ...
... d ...
1 e ...
... ... ...
@Lauren_Schaefer
Multi-Record
ACID Transaction
Multi-Document
ACID Transaction
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
@Lauren_Schaefer
TermMappingSummary
Column
Field
Row
Document
Table
Collection
Database
Database
Index
Index
Join
Embedding
View
View
Transaction
Transaction
@Lauren_Schaefer
Don’tbe
RonSwanson
(in this particular case)
@Lauren_Schaefer
Changeyour
mindset&
getthefullvalueof
document
databases
@Lauren_Schaefer
Additional
Resources
• SQL to MongoDB Blog (blog series)
• Quick Start: MongoDB and Node.js (blog series)
• Advanced Schema Design Patterns (webinar)
• Building with Patterns: A Summary (blog series)
• M320: Data Modeling (MongoDB University Course)
• JSON Schema Validation – Locking down your model
the smart way (blog)
@Lauren_Schaefer
Changeyour
mindset&
getthefullvalueof
document
databases
Give document databases a try using MongoDB Atlas
Get the slides on my Twitter page: @Lauren_Schaefer @Lauren_Schaefer

More Related Content

More from Lauren Hayward Schaefer

Level Up Your Technical Career by Writing
Level Up Your Technical Career by WritingLevel Up Your Technical Career by Writing
Level Up Your Technical Career by WritingLauren Hayward Schaefer
 
5 Things I Learned While Modeling Data in MongoDB
5 Things I Learned While Modeling Data in MongoDB5 Things I Learned While Modeling Data in MongoDB
5 Things I Learned While Modeling Data in MongoDBLauren Hayward Schaefer
 
How to Raise Your Profile as a Developer (And Why You Should Bother!)
How to Raise Your Profile as a Developer (And Why You Should Bother!)How to Raise Your Profile as a Developer (And Why You Should Bother!)
How to Raise Your Profile as a Developer (And Why You Should Bother!)Lauren Hayward Schaefer
 
Building CI/CD Pipelines for MongoDB Realm Apps
Building CI/CD Pipelines for MongoDB Realm AppsBuilding CI/CD Pipelines for MongoDB Realm Apps
Building CI/CD Pipelines for MongoDB Realm AppsLauren Hayward Schaefer
 
DevOps + MongoDB Realm Serverless Functions = 🤩
DevOps + MongoDB Realm Serverless Functions = 🤩DevOps + MongoDB Realm Serverless Functions = 🤩
DevOps + MongoDB Realm Serverless Functions = 🤩Lauren Hayward Schaefer
 
Stop! Don't make these mistakes in your document database!
Stop! Don't make these mistakes in your document database!Stop! Don't make these mistakes in your document database!
Stop! Don't make these mistakes in your document database!Lauren Hayward Schaefer
 
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetJumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetLauren Hayward Schaefer
 
From SQL to NoSQL -- Changing Your Mindset
From SQL to NoSQL -- Changing Your MindsetFrom SQL to NoSQL -- Changing Your Mindset
From SQL to NoSQL -- Changing Your MindsetLauren Hayward Schaefer
 
Look, Ma! No servers! Serverless application development with MongoDB Stitch
Look, Ma! No servers! Serverless application development with MongoDB StitchLook, Ma! No servers! Serverless application development with MongoDB Stitch
Look, Ma! No servers! Serverless application development with MongoDB StitchLauren Hayward Schaefer
 
Jumpstart! Building Your First MongoDB App Using Atlas & Stitch
Jumpstart! Building Your First MongoDB App Using Atlas & StitchJumpstart! Building Your First MongoDB App Using Atlas & Stitch
Jumpstart! Building Your First MongoDB App Using Atlas & StitchLauren Hayward Schaefer
 
Dissecting Professor M for Best Practices
Dissecting Professor M for Best PracticesDissecting Professor M for Best Practices
Dissecting Professor M for Best PracticesLauren Hayward Schaefer
 
Building awesome sample apps that actually provide value
Building awesome sample apps that actually provide valueBuilding awesome sample apps that actually provide value
Building awesome sample apps that actually provide valueLauren Hayward Schaefer
 

More from Lauren Hayward Schaefer (20)

Level Up Your Technical Career by Writing
Level Up Your Technical Career by WritingLevel Up Your Technical Career by Writing
Level Up Your Technical Career by Writing
 
How to Raise Your Profile Worksheet
How to Raise Your Profile WorksheetHow to Raise Your Profile Worksheet
How to Raise Your Profile Worksheet
 
5 Things I Learned While Modeling Data in MongoDB
5 Things I Learned While Modeling Data in MongoDB5 Things I Learned While Modeling Data in MongoDB
5 Things I Learned While Modeling Data in MongoDB
 
How to Raise Your Profile as a Developer (And Why You Should Bother!)
How to Raise Your Profile as a Developer (And Why You Should Bother!)How to Raise Your Profile as a Developer (And Why You Should Bother!)
How to Raise Your Profile as a Developer (And Why You Should Bother!)
 
Building CI/CD Pipelines for MongoDB Realm Apps
Building CI/CD Pipelines for MongoDB Realm AppsBuilding CI/CD Pipelines for MongoDB Realm Apps
Building CI/CD Pipelines for MongoDB Realm Apps
 
DevOps + MongoDB Realm Serverless Functions = 🤩
DevOps + MongoDB Realm Serverless Functions = 🤩DevOps + MongoDB Realm Serverless Functions = 🤩
DevOps + MongoDB Realm Serverless Functions = 🤩
 
Stop! Don't make these mistakes in your document database!
Stop! Don't make these mistakes in your document database!Stop! Don't make these mistakes in your document database!
Stop! Don't make these mistakes in your document database!
 
Making #RemoteWork Actually Work
Making #RemoteWork Actually WorkMaking #RemoteWork Actually Work
Making #RemoteWork Actually Work
 
DevOps + MongoDB Serverless = 
DevOps + MongoDB Serverless = DevOps + MongoDB Serverless = 
DevOps + MongoDB Serverless = 
 
MongoDB: Back to Basics
MongoDB:  Back to BasicsMongoDB:  Back to Basics
MongoDB: Back to Basics
 
Intro to MongoDB Workshop
Intro to MongoDB WorkshopIntro to MongoDB Workshop
Intro to MongoDB Workshop
 
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetJumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
 
Does remote work *really* work?
Does remote work *really* work?Does remote work *really* work?
Does remote work *really* work?
 
From SQL to NoSQL -- Changing Your Mindset
From SQL to NoSQL -- Changing Your MindsetFrom SQL to NoSQL -- Changing Your Mindset
From SQL to NoSQL -- Changing Your Mindset
 
Look, Ma! No servers! Serverless application development with MongoDB Stitch
Look, Ma! No servers! Serverless application development with MongoDB StitchLook, Ma! No servers! Serverless application development with MongoDB Stitch
Look, Ma! No servers! Serverless application development with MongoDB Stitch
 
Does remote work *really* work?
Does remote work *really* work?Does remote work *really* work?
Does remote work *really* work?
 
Jumpstart! Building Your First MongoDB App Using Atlas & Stitch
Jumpstart! Building Your First MongoDB App Using Atlas & StitchJumpstart! Building Your First MongoDB App Using Atlas & Stitch
Jumpstart! Building Your First MongoDB App Using Atlas & Stitch
 
Dissecting Professor M for Best Practices
Dissecting Professor M for Best PracticesDissecting Professor M for Best Practices
Dissecting Professor M for Best Practices
 
Building awesome sample apps that actually provide value
Building awesome sample apps that actually provide valueBuilding awesome sample apps that actually provide value
Building awesome sample apps that actually provide value
 
Getting Started with Graph Databases
Getting Started with Graph Databases Getting Started with Graph Databases
Getting Started with Graph Databases
 

Recently uploaded

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 

Recently uploaded (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 

From Tables to Documents—Changing Your Database Mindset

  • 1. From Tables to Documents— Changing Your Database Mindset Lauren Schaefer, Developer Advocate, MongoDB
  • 2. Parks and Recreation, Season 6, Episode 14 @Lauren_Schaefer
  • 6. Parks and Recreation, Season 6, Episode 14 @Lauren_Schaefer
  • 8. From Tables to Documents Changing Your Database Mindset @Lauren_Schaefer
  • 9. Themental journey from tables to documents 1. Model data in tables and documents 2. Map terms & concepts from tables to documents 3. Q&A @Lauren_Schaefer
  • 10. Themental journey from tables to documents 1. Model data in tables and documents 2. Map terms & concepts from tables to documents 3. Q&A @Lauren_Schaefer
  • 14. Let’s talk about documents { field: value, field: value, field: value } @Lauren_Schaefer
  • 16. ID first_name last_name cell city 1 Leslie Yepp 8125552344 Pawnee Users @Lauren_Schaefer
  • 17. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee" } ID first_name last_name cell city 1 Leslie Yepp 8125552344 Pawnee UsersUsers @Lauren_Schaefer
  • 18. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee" } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers @Lauren_Schaefer
  • 19. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers @Lauren_Schaefer
  • 20. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers @Lauren_Schaefer
  • 21. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies @Lauren_Schaefer
  • 22. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies @Lauren_Schaefer
  • 23. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies @Lauren_Schaefer
  • 24. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory @Lauren_Schaefer
  • 25. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory @Lauren_Schaefer
  • 26. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory @Lauren_Schaefer
  • 27. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory @Lauren_Schaefer
  • 28. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory @Lauren_Schaefer
  • 29. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": "8125559347", "city": "Pawnee" } @Lauren_Schaefer
  • 30. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": "8125559347", "city": "Pawnee" } @Lauren_Schaefer
  • 31. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": "8125559347", "city": "Pawnee", "hobbies": [ "woodworking", "fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": "CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } @Lauren_Schaefer
  • 32. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": "8125559347", "city": "Pawnee", "hobbies": [ "woodworking", "fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": "CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } @Lauren_Schaefer
  • 33. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": "8125559347", "city": "Pawnee", "hobbies": [ "woodworking", "fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": "CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } @Lauren_Schaefer
  • 34. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ] } @Lauren_Schaefer
  • 35. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ] } @Lauren_Schaefer
  • 36. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ] } @Lauren_Schaefer
  • 37. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude school 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL Pawnee Elementar y UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ] } @Lauren_Schaefer
  • 38. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude school 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL Pawnee Elementar y UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ] } @Lauren_Schaefer
  • 39. { "_id": 1, "first_name": "Leslie", "last_name": "Yepp", "cell": "8125552344", "city": "Pawnee", "location": [ -86.536632, 39.170344 ], "hobbies": [ "scrapbooking", "eating waffles", "working” ], "jobHistory": [ { "title": "Deputy Director", "yearStarted": 2004 }, { "title": "City Councillor", "yearStarted": 2012 }, { "title": "Director, National Parks Service, Midwest Branch", "yearStarted": 2014 } ] } ID first_name last_name cell city latitude longitude school 1 Leslie Yepp 8125552344 Pawnee 39.170344 -86.536632 NULL 2 Ron Swandaughte r 8125559347 Pawnee NULL NULL NULL 3 Lauren Burhug NULL Pawnee NULL NULL Pawnee Elementar y UsersUsers ID user_id hobby 10 1 scrapbooking 11 1 eating waffles 12 1 working 13 2 woodworking 14 2 fishing 15 3 soccer Hobbies ID user_id job_title year_started 20 1 Deputy Directory 2004 21 1 City Councilor 2012 22 1 Director, National Parks Service, Midwest Branch 2014 23 2 Director 2002 24 2 CEO, Kinda Good Building Company 2014 JobHistory { "_id": 1, "first_name": "Ron", "last_name": "Swandaughter", "cell": ”8125559347", "city": "Pawnee", "hobbies": [ ”woodworking", ”fishing" ], "jobHistory": [ { "title": "Director", "yearStarted": 2002 }, { "title": ”CEO, Kinda Good Building Company", "yearStarted": 2014 } ] } { "_id": 3, "first_name": "Lauren", "last_name": "Burhug", "city": "Pawnee", "hobbies": [ "soccer" ], "school": "Pawnee Elementary" } @Lauren_Schaefer
  • 41. FlexibleSchema Don’t panic! Use schema validation. @Lauren_Schaefer
  • 42. Themental journey from tables to documents 1. Model data in tables and documents 2. Map terms & concepts from tables to documents 3. Q&A @Lauren_Schaefer
  • 43. Row Document { ... a: “b” ... } ID a ... 1 b ... 2 ... ... 3 ... ... @Lauren_Schaefer
  • 44. Row(s) Document { ... a: “b” ... } ID a ... 1 b ... 2 ... ... 3 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... @Lauren_Schaefer
  • 45. Column Field ID a ... 1 b ... 2 c ... 3 ... ... { ... a: “b” ... } { ... a: “c” ... } @Lauren_Schaefer
  • 46. Table Collection { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } @Lauren_Schaefer
  • 47. Database Database { ... } { ... } { ... } { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... @Lauren_Schaefer
  • 48. Index Index { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... @Lauren_Schaefer
  • 49. View View { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } @Lauren_Schaefer
  • 50. Join Embedding { ... a: “b”, ... c: { d: “e” ... }, ... } ID a ... 1 b ... 2 ... ... 3 ... ... ... d ... 1 e ... ... ... ... @Lauren_Schaefer
  • 51. Multi-Record ACID Transaction Multi-Document ACID Transaction { ... } { ... } { ... } { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... @Lauren_Schaefer
  • 55. Additional Resources • SQL to MongoDB Blog (blog series) • Quick Start: MongoDB and Node.js (blog series) • Advanced Schema Design Patterns (webinar) • Building with Patterns: A Summary (blog series) • M320: Data Modeling (MongoDB University Course) • JSON Schema Validation – Locking down your model the smart way (blog) @Lauren_Schaefer
  • 56. Changeyour mindset& getthefullvalueof document databases Give document databases a try using MongoDB Atlas Get the slides on my Twitter page: @Lauren_Schaefer @Lauren_Schaefer

Editor's Notes

  1. Hey everyone! I don’t know about you, but the pandemic has me eating a lot of comfort food and watching a lot of comfort tv lately. My favorite comfort tv is the show Parks and Recreation. One of the things that makes the show so amazing is the characters. I want to introduce you to Ron Swanson.
  2. Ron is an old school guy. He’s a bit set in his ways, he likes his privacy, and he likes to stay off the grid. Now in Season 6, episode 14, Ron discovers Yelp. He loves the idea of being able to review places he’s been. However, Yelp is way too “on-the-grid” for Ron. So Ron uses the Internet to look up the physical addresses of where he wants to snail-mail his reviews and then pulls out his big old typewriter to start typing his reviews. Ron writes some pretty great reviews. Here is one of my favorites.
  3. Dear Frozen Yoguart, You are the celery of desserts http://www.breathtakingandinappropriate.com/2014/09/ron-swanson-has-no-time-for-frozen.html
  4. Be ice cream or be nothing http://www.breathtakingandinappropriate.com/2014/09/ron-swanson-has-no-time-for-frozen.html
  5. Zero stars http://www.breathtakingandinappropriate.com/2014/09/ron-swanson-has-no-time-for-frozen.html
  6. Now this is a pretty great review. But I see 3 problems with his approach. Snail mail is way slower than posting the review to yelp where it will be instantly available The businesses he’s reviewing may never open the review because they may just assume it’s junk mail No one else will benefit from the review. I don’t know about you, but I live for these kinds of reviews online. Ron was inspired by Yelp and he saw the value in the technology, but he didn’t change his old school mindset in order to really get the value out of it. This is what we see sometimes as people move from tabular/relational databases to document databases like MongoDB. People see the value of document databases and are inspired by the technology, but they bring with them their old mindsets, so they don’t get the full value of document databases. I don’t want this to happen to you. I want to see you be really successful as you work with document databases.
  7. Before we dive in, let me introduce myself. My name is Lauren Schaefer. I took a database course in college that was all about best practices for relational databases. I began my career at IBM where I spent 8 years as a software engineer. For a lot of that time I used DB2. Toward the end of my time there, my team started getting flexibility in what database we wanted to use, so I started trying out NoSQL databases. To be honest, I didn’t really get the hype. Without a doubt, NoSQL databases were easy to get started using. But I brought with me my relational database mindset, so I kept thinking about my data in rows and columns even though I wasn’t using rows and columns anymore. It worked, but it wasn’t great. I joined MongoDB about a year and a half ago, and I’ve worked through the process of changing my mindset in how I think about storing data. And I’m so happy I did, because it’s really easy to work with data in the apps that I build now. Today, I’m going to share with you what I’ve learned as I’ve gone on the journey of moving from tables to documents. I’d love to connect with you on social. You can find me on both Twitter and TikTok with the handle Lauren_Schaefer. I don’t really know what I’m doing on TikTok, but I’m having a lot of fun doing it.
  8. Today we’re going to be talking about moving from tables to documents. When I say tables, I mean a tabular or relational database. For example, you might have experience using MySQL or Oracle. We’ll dive into what document databases are in just a few minutes. If you’re here, I’m going to assume You have experience with relational databases Minimal to no experience with document databases
  9. Today, we’re going to go on a mental journey from tables to documents. I’m going to kick things off by working through an example of how you would model the same data in both tables and documents. Then I’ll map the terms and concepts you’re familiar with in tabular databases to similar terms and concepts in document databases. Then we’ll wrap up with some Q&A. I’m happy to answer questions about what I’m talking about here today, what life is like here at MongoDB, how I got to where I am in my career, how I balance being a working mom, or whatever else is on your mind.
  10. Let’s jump right in
  11. Let’s talk about documents. [CLICK] No, I’m not talking about Word documents.
  12. I’m talking about JSON documents. JSON stands for JavaScript Object Notation. If you’ve used any of the C-family of programming languages such as C, C#, Go, Java, JavaScript, PHP, or Python, documents will probably feel pretty comfortable to you. Documents typically store information about one object as well as any information related to that object. 
  13. Every document begins and ends with curly braces.
  14. Inside of those curly braces are field/value pairs. The great thing about documents is that they can be incredibly rich. Values can be a variety of types including strings, numbers, arrays, dates, timestamps, or even objects. So you can have objects within a document. You’ll see what that looks like in just a moment. When people talk about document databases, they’ll often use the term nonrelational. But that doesn’t mean document databases don’t store relationships. That was a double negative. Stick with me. Document databases store relationships really well – it’s just different than the way relational databases do.
  15. Let’s walk through an example of how you would model the same data in a relational, tabular database vs a document database. Let's say we need to store information about a user named Leslie. 
  16. Let’s begin with her contact information. In a relational database, we'll create a table named Users. We can create columns for each piece of contact information we need to store: first name, last name, cell phone number, and city. To ensure we have a unique way to identify each row, we'll include an ID column.
  17. Now let's store that same information in a document. We can create a new document for Leslie where we'll add field/value pairs for each piece of contact information we need to store. As you can see we have field/value pairs for first name, last name, cell and city. We'll use _id to uniquely identify each document. We'll store this document in a collection named Users.
  18. Now that we've stored Leslie's contact information, let's store the coordinates of her current location. When using a relational database, we'll need to split the latitude and longitude between two columns.
  19. Document databases support arrays, so we can store the latitude and longitude together in a single field. We’ll call that field location.
  20. We're successfully storing Leslie's contact information and current location. Now let's store her hobbies. When using a relational database, we could choose to add more columns to the Users table.
  21. However, since a single user could have many hobbies (meaning we need to represent a one-to-many relationship), we're more likely to create a separate table just for hobbies. Each row in the table will contain information about one hobby for one user. When we need to retrieve Leslie's hobbies, we'll join the Users table and our new Hobbies table.
  22. Since document databases support arrays, we can simply add a new field named "hobbies" to our existing document for Leslie. The array can contain as many or as few hobbies as we need. When we need to retrieve Leslie's hobbies, we don't need to do an expensive join to bring the data together; we can simply retrieve her document in the Users collection.
  23. Let's say we also need to store Leslie's job history.
  24. Just as we did with hobbies, we're likely to create a separate table just for job history information. Each row in the table will contain information about one job for one user.
  25. So far, we've used arrays to store geolocation data and a list of Strings. Arrays can contain values of any type, including objects.
  26. Let's create an object for each job Leslie has held and store those objects in an array. As you can see we have a job history field that stores an array. Inside of that array, we have an object for when she was the Deputy Director, an object for when she was a City Councillor, and an object for when she was director of the National Parks Service’s Midwest branch.
  27. Now that we've decided how we'll store information about our users in both tables and documents, let's store information about Ron. Ron will have almost all of the same information as Leslie. However, Ron does his best to stay off the grid, so he will not be storing his location in the system.
  28. Let's begin by examining how we would store Ron's information in the same tables that we used for Leslie's. When using a relational database, we are required to input a value for every cell in the table. We will represent Ron's lack of location data with NULL. The problem with using NULL is that it's unclear whether the data does not exist or if the data is just unknown, so many people discourage the use of NULL.
  29. In document databases, we have the option of representing Ron's lack of location data in two ways: we can omit the location field from the document or we can set location to null. Best practices suggest that we omit the location field to save space. You can choose if you want omitted fields and fields set to null to represent different things in your applications.
  30. Ron has some hobbies and job history, so we’ll add his information to those tables.
  31. And we can add that information to his document as well. The structure of Ron’s document looks pretty similar to Leslie’s.
  32. Let's say we are feeling pretty good about our data models and decide to launch our apps using them. Then we discover we need to store information about a new user: Lauren Burhug. She's a fourth grade student who Ron teaches about government. We need to store a lot of the same information about Lauren as we did with Leslie and Ron: her first name, last name, city, and hobbies. However, Lauren doesn't have a cell phone, location data, or job history. We also discover that we need to store a new piece of information: her school.
  33. Let's begin by storing Lauren's information in the tables as they already exist.
  34. We can create a new document for Lauren and include the data we have for her in it.
  35. Now let’s talk about how to store information about Lauren’s school in our tables. We have two options. We can choose to add a column to the existing Users table, or we can create a new table named Schools. Let's say we choose to add a column named "school" to the Users table. Depending on our access rights to the database, we may need to talk to the DBA and convince them to add the column.
  36. Maybe we have to do a little begging to get our DBA to add the column. Maybe we have to do a little bribing – maybe we bring our DBA their favorite donut. Or maybe we bring our manager along to pressure the DBA into agreeing.
  37. If our DBA agrees, the database will likely need to be taken down, the "school" column will need to be added, NULL values will be stored in every row in the Users table where a user does not have a school, and the database will need to be brought back up. It’s doable but it can be a little painful.
  38. Now let’s talk about how to store Lauren’s school in documents.
  39. We can simply add a new field named "school" to Lauren's document. We do not need to make any modifications to Leslie's document or Ron's document when we add the new "school" field to Lauren's document. Document databases have a flexible schema, so every document in a collection does not need to have the same fields.
  40. Some of you might be starting to panic at the idea of a flexible schema. (I know I started to panic a little when I was introduced to the idea.) http://gph.is/28MrIOY
  41. Don't panic! This flexibility can be hugely valuable as your application's requirements evolve and change. Also, some document databases like MongoDB provide schema validation so you can lock down your schema as much or as little as you’d like when you’re ready. http://gph.is/28MrIOY
  42. Now that we’re starting to get the idea of how tables and documents are similar and different, let’s do some explicit term mapping. On the left side of the screen you’ll see tabular or relational database terms and on the right side of the screen you’ll see document database terms.
  43. First up, we saw this a bit in our earlier example: a row maps to a document
  44. Or, depending on how you’ve normalized your data, rows from multiple tables could map to a single document.
  45. A column maps roughly to a field.
  46. In a relational database, groups of rows are stored in tables. In a document database, groups of documents are stored in collections. So tables map to collections. The next few terms will probably feel pretty comfortable to those of you with relational database backgrounds as the terminology is basically the same between the two.
  47. Just like you store groups of tables in a relational database, you store groups of collections in a document database.
  48. Indexes are fairly similar between the two. Indexes help speed up your read queries.
  49. Views are pretty similar in both.
  50. There are a few different ways to handle joins in document databases. The general recommendation is that, if you have related information that you would put in a separate table in a relational database, you should embed that information in a single document when working in a document database. The rule of thumb is that data that is accessed together should be stored together. Let me say that again: data this accessed together should be stored together. So, if you’ll be frequently accessing information together that you would have put in separate tables, you should likely just embed it in a document. Depending on the document database you’re using, there are other options for joins as well. MongoDB supports references between the documents similar to how you would use a foreign key. MongoDB also has an operation called $lookup to support a left outer join. I’m not going to go any deeper into those today, but I want you to know that the options exist.
  51. Finally, let’s talk about ACID transactions.  Transactions group database operations together so they either all succeed or none succeed.  If you did some research online about relational databases vs document databases before coming here today, you probably saw something about document databases not supporting transactions as a major drawback. If you care about data integrity—and really, who doesn’t?—that’s a pretty scary sounding drawback. Some document databases support ACID transactions while others do not. In relational databases, we call these multi-record ACID transactions. In document databases, we call these multi-document ACID transactions.   However, when you model your data for document databases, you’ll find that most of the time you don’t actually need to use a transaction. So don’t get freaked out if you’re looking at drawbacks of document databases and see “no transactions” listed. MongoDB supports transactions, but chances are good that you won’t actually need them.
  52. To wrap up this section, I created this term mapping summary for you. It’s way too much information for you to read now. But you can take a screenshot and tweet it. Or you can print it and hang it up at your desk. Whatever you need to do. The first three are the most important A row maps to a document A column maps to a field A table maps to a collection
  53. If I had to sum up this presentation in one idea, I would say this. Don’t be Ron Swanson--in this particular case because Ron Swanson is amazing in so many other ways—but don’t be Ron Swanson http://gph.is/XK6p3t
  54. Change your mindset and get the full value of document databases http://gph.is/XK6p3t
  55. At the end of these slides, I’ve included a list of additional resources. The top resource listed here is a blog series that I wrote that has content very similar to what I presented today. If later you want to reference the material I covered, that’s a great place to start.
  56. One of the best ways to learn a new technology is by trying it out. MongoDB Atlas is a fully-managed document database service. It has a perpetually free tier that is great for learning if you’d like to try it out. If you hop back a slide, I have a link to a Quick Start blog series that will walk you through trying it out. If you’d like to get a copy of my slides, check out my Twitter page. I’m Lauren_Schaefer. Now I want to open the floor for Q&A. You should be able to ask questions in the chat. I’m happy to answer questions about what I talked about today. I’m also happy to answer any other questions you may have like what life is like here at MongoDB or how I got to where I am in my career. I’m married with a 4 year old, so I’m also happy to talk about how I balance being a working mom. Please ask whatever is on your mind. http://gph.is/XK6p3t