SlideShare una empresa de Scribd logo
1 de 97
Descargar para leer sin conexión
#MDBlocal
[Jumpstart] From SQL to NoSQL:
Changing your Mindset
@JoeKarlsson1
Joe Karlsson
Did you know that the
two main bottlenecks
for web app
performance are:
@JoeKarlsson1Source: https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
* Network speed
* Database execution speed
We can only
control one of
these things
@JoeKarlsson1Source: https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
@JoeKarlsson1
{
name: “Joe Karlsson”,
company: “MongoDB”,
pronouns: “He/They”,
title: [
“Developer Advocate”,
“Software Engineer”
],
twitter: “@JoeKarlsson1”,
website: “joekarlsson.com”,
}
@JoeKarlsson1
MagicMirror^2
@JoeKarlsson1
@JoeKarlsson1
Moodlite
@JoeKarlsson1
@JoeKarlsson1
Want to watch
me make stuff?
https://www.twitch.tv/joe_karlsson
@JoeKarlsson1
Before we
get started…
@JoeKarlsson1
Thank you so
much for coming!
@JoeKarlsson1
Who’s this
talk for?
@JoeKarlsson1
@JoeKarlsson1
How’s this talk
going to work?
@JoeKarlsson1
Feel free to ask
questions at
anytime
@JoeKarlsson1
Want to
follow along?
@JoeKarlsson1
http://bit.ly/FromSQLtoNoSQLChicago
Get the slides/
resources on my
Twitter after the
talk:
@JoeKarlsson1
@JoeKarlsson1
Quick
Audience
Poll
@JoeKarlsson1
@JoeKarlsson1
Agenda
1.Map terms & concepts from SQL to MongoDB
2.Discover the 4 humongous advantages of MongoDB
3.Change your mindset in 3 key ways
@JoeKarlsson1
Agenda
1.Map terms & concepts from SQL to MongoDB
2.Discover the 4 humongous advantages of MongoDB
3.Change your mindset in 3 key ways
@JoeKarlsson1
Row Column Table Database Index Join Join
Left Outer
Join
Recursive
Common Table
Expressions
View Transaction
Document Field Collection Database Index Embedding
Database
References
$lookup $graphLookup View Transaction
@JoeKarlsson1
MongoDB stores data in documents
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
MongoDB stores data in documents
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
Modeling data in MongoDB vs SQL
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
@JoeKarlsson1
Modeling data in MongoDB vs SQL
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
ID first_name surname cell city location_x location_y
1 Paul Miller 447557505611 London 45.123 47.232
Users
@JoeKarlsson1
Modeling data in MongoDB vs SQL
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
ID user_id profession
10 1 banking
11 1 finance
12 1 trader
Professions
ID first_name surname cell city location_x location_y
1 Paul Miller 447557505611 London 45.123 47.232
Users
@JoeKarlsson1
Modeling data in MongoDB vs SQL
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
ID user_id model year
20 1 Bentley 1973
21 1 Rolls Royce 1965
Cars
ID user_id profession
10 1 banking
11 1 finance
12 1 trader
Professions
ID first_name surname cell city location_x location_y
1 Paul Miller 447557505611 London 45.123 47.232
Users
@JoeKarlsson1
Modeling data in MongoDB vs SQL
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
ID user_id model year
20 1 Bentley 1973
21 1 Rolls Royce 1965
Cars
ID user_id profession
10 1 banking
11 1 finance
12 1 trader
Professions
ID first_name surname cell city location_x location_y
1 Paul Miller 447557505611 London 45.123 47.232
Users
@JoeKarlsson1
Collections vs Tables
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
{
first_name: ”Joe",
surname: ”Karlsson",
cell: ”1235552222",
city: ”Minneapolis”,
profession: [”software engineer", ”developer advocate"],
}
{
first_name: ”BMO",
surname: ”Karlsson",
city: ”Minneapolis",
}
UsersUsers
ID first_name surname cell city
location_
x
location_y
1 Paul Miller 447557505611 London 45.123 47.232
2 Joe Karlsson 1235552222 Minneapolis NULL NULL
3 Sydney Schaefer NULL Minneapolis NULL NULL
@JoeKarlsson1
Collections vs Tables
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
{
first_name: ”Joe",
surname: ”Karlsson",
cell: ”1235552222",
city: ”Minneapolis”,
profession: [”software engineer", ”developer advocate"],
}
{
first_name: ”BMO",
surname: ”Karlsson",
city: ”Minneapolis",
}
UsersUsers
ID first_name surname cell city
location_
x
location_y
1 Paul Miller 447557505611 London 45.123 47.232
2 Joe Karlsson 1235552222 Minneapolis NULL NULL
3 BMO Karlsson NULL Minneapolis NULL NULL
@JoeKarlsson1
Collections vs Tables
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
{
first_name: ”Joe",
surname: ”Karlsson",
cell: ”1235552222",
city: ”Minneapolis”,
profession: [”software engineer", ”developer advocate"],
}
{
first_name: ”BMO",
surname: ”Karlsson",
city: ”Minneapolis",
}
UsersUsers
ID first_name surname cell city
location_
x
location_y
1 Paul Miller 447557505611 London 45.123 47.232
2 Joe Karlsson 1235552222 Minneapolis NULL NULL
3 BMO Karlsson NULL Minneapolis NULL NULL
Don’t panic!
Use schema validation.
Flexible
schema

database
Document Row(s)
ID a ...
1 b ...
2 ... ...
3 ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
{
...

a: “b”

...
}
Field
ID a ...
1 b ...
2 c ...
3 ... ...
{
...

a: “b”

...
}
{
...

a: “c”

...
}
Column
TableCollection
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
{
...
}
{
...
}
@JoeKarlsson1
Time for a
terrible joke
@JoeKarlsson1
So a DBA walks

into a NoSQL bar…
But immediately leaves because
they couldn’t find table.
@JoeKarlsson1
DatabaseDatabase
... ... ...
... ... ...
... ... ...
... ... ...
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
IndexIndex
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
ViewView
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
{
...
} {
...
}
Embedding
{
...

a: “b”,

...
c: {

d: “e”

...

},

...
}
ID a ...
1 b ...
2 ... ...
3 ... ...
... d ...
1 e ...
... ... ...
Join
Multi-Record ACID
Transaction
Multi-Document
ACID
Transaction
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
@JoeKarlsson1
The journey from SQL to MongoDB
@JoeKarlsson1
Row Column Table Database Index Join Join
Left Outer
Join
Recursive
Common Table
Expressions
View Transaction
Document Field Collection Database Index Embedding
Database
References
$lookup $graphLookup View Transaction
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
Agenda
1.Map terms & concepts from SQL to MongoDB
2.Discover the 4 humongous advantages of
MongoDB
3.Change your mindset in 3 key ways
@JoeKarlsson1
1.Program faster
2.Pivot easier
3.Query faster
4.Scale Cheaper
@JoeKarlsson1
Program faster!
Update Your Profile
Documents map to data structures in most popular languages.
@JoeKarlsson1
Program faster!
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
}
ID first_name surname cell city location_x location_y
1 Paul Miller 447557505611 London 45.123 47.232
Users
ID user_id profession
10 1 banking
11 1 finance
12 1 trader
Professions
import pymongo

from pymongo import MongoClient
# CONNECT TO THE DB
client = MongoClient()
client =

pymongo.MongoClient("mongodb+srv://

username:password@cluster0nsdia.

mongodb.net/test?retryWrites=true")
db = client.fabapp


# THE ID OF THE USER WHOSE PROFILE WE
WILL BE RETRIEVING AND UPDATING
userId = 1
Program faster!
import mysql.connector


# CONNECT TO THE DB
mydb = mysql.connector.connect(

host="localhost",

user=”username",

passwd=”password",

database=”fabapp”

)
mycursor = mydb.cursor()


# THE ID OF THE USER WHOSE PROFILE WE
WILL BE RETRIEVING AND UPDATING
userId = 1
# GET THE USER'S PROFILE INFORMATION
### Pull the info from the Users table
& put it in the user dictionary
sql = "Select * FROM Users WHERE
Users.ID=%s”

values = (userId,)

mycursor.execute(sql, values)

result = mycursor.fetchone()
user = {

"first_name": result[1],

"surname": result[2],

"cell": result[3],

"city": result[4],

"location_x": result[5],

"location_y": result[6]

}
# GET THE USER'S PROFILE INFORMATION
## We can pull all of the info from
the same document since we used
embedding
user = db['Users'].find_one({"_id":
userId})
Program faster!
### Pull the info from the Professions
table & put it in the user dictionary
sql = "Select * FROM Professions WHERE

Professions.user_id=%s”

values = (userId,)

mycursor.execute(sql, values)

results = mycursor.fetchall()
professions = []

for result in results:

professions.append(result[2])

user["professions"] = professions
# UPDATE THE USER DICTIONARY BASED
ON USER INPUT IN THE APP
### We'll update the user
dictionary manually for simplicity
user = {

"first_name": "NewFirst",

"surname": "NewSurname",

"cell": "123-456-7890",

"city": "NewCity",

"location": [40.762, -73.979],

"professions": [”Manager",
"Engineer"]

}
Program faster!
# UPDATE THE USER DICTIONARY BASED
ON USER INPUT IN THE APP
### We'll update the user dictionary
manually for simplicity
user = {

"first_name": "NewFirst",

"surname": "NewSurname",

"cell": "123-456-7890",

"city": "NewCity",

"location_x": 40.762, 

"location_y": 73.979,

"professions": [”Manager",
"Engineer"]

}
# UPDATE THE USER'S PROFILE IN THE DATABASE
### First update what is stored in the
Users table
sql = "UPDATE Users SET first_name=%s,
surname=%s, cell=%s, city=%s,
location_x=%s, location_y=%s WHERE (ID=%s)"

values = (

user["first_name"], 

user["surname"], 

user["cell"], 

user["city"], 

user["location_x"], 

user["location_y"], 

userId)

mycursor.execute(sql, values)
mydb.commit()
# UPDATE THE USER'S PROFILE IN THE
DATABASE
### Since the user's data is stored
in a single document, we only have to
make one update
result = db['Users'].update_one(

{"_id": userId}, {"$set": user})


Program faster!
### Delete existing records in
Professions table and add new ones
sql = "DELETE FROM Professions WHERE
user_id=%s”

values = (userId,)

mycursor.execute(sql, values)

mydb.commit()
if(len(user["professions"]) > 0):

sql = "INSERT INTO Professions 

(user_id,profession) VALUES
(%s, %s)”

values = []

for profession in
user["professions"]:

values.append((userId,
profession))

mycursor.executemany(sql,values)

mydb.commit()
30 lines of code
Program faster!
73 lines of code
@JoeKarlsson1
Pivot easier!
Easily change the shape of your data as your app evolves.
SQLMongoDB
{

a: “b”,

c: “one”,

e: “f”
}
{

a: “b”,

c: 1,

new: “no biggee”
}
ALTER TABLE `mydb`.`letters_table`
DROP COLUMN `e`,
ADD COLUMN `New` VARCHAR(45) NULL AFTER `C`,
CHANGE COLUMN `C` `C` INT NULL DEFAULT NULL ;
@JoeKarlsson1
Query faster!
Stop doing expensive joins to get your data.
SQLMongoDB
ID a ...
1 b ...
2 ... ...
3 ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
... ... ...
{
...

a: “b”,

...
c: {

d: “e”

...

},

...
}
@JoeKarlsson1
Scale cheaper!
As the size of your server grows, scale horizontally.
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
1. Program faster
# UPDATE THE USER'S PROFILE IN THE DATABASE
### First update what is stored in the Users table
sql = "UPDATE Users SET first_name=%s, surname=%s, cell=%s,
city=%s, location_x=%s, location_y=%s WHERE (ID=%s)"

values = (

user["first_name"], 

user["surname"], 

user["cell"], 

user["city"], 

user["location_x"], 

user["location_y"], 

userId)

mycursor.execute(sql, values)
mydb.commit()
# UPDATE THE USER'S PROFILE IN THE DATABASE
### Since the user's data is stored in a single
document, we only have to make one update
result = db['Users'].update_one(

{"_id": userId}, {"$set": user})


@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
2. Scale cheaper
1. Program faster
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3. Query faster
2. Scale cheaper
1. Program faster
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
4. Pivot easier
3. Query faster
2. Scale cheaper
1. Program faster
Agenda
1.Map terms & concepts from SQL to MongoDB
2.Discover the 4 humongous advantages of MongoDB
3.Change your mindset in 3 key ways
@JoeKarlsson1
1.Not all documents in a collection need to
have the same fields.
2.Data that is accessed together should be
stored together.
3.Stop using transactions regularly.
@JoeKarlsson1
Not all documents in a collection need to
have the same fields.
@JoeKarlsson1
Not all documents in a collection need to
have the same fields.
The Polymorphic Pattern
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
{
first_name: ”Joe",
surname: ”Karlsson",
cell: ”1235552222",
city: ”Minneapolis”,
profession: [”software engineer", ”developer advocate"],
}
{
first_name: ”BMO",
surname: ”Karlsson",
city: ”Minneapolis",
}
@JoeKarlsson1
Not all documents in a collection need to
have the same fields.
The Outlier Pattern
{
_id: ”JoeKarlsson1",
displayName: ”JoeKarlsson1”, 

numFollowers: 2095
followers: [

“jessicaewest”,

“wesley83”, 

“GraceFr”

...
]
}
{
_id: ”KimKardashian",
displayName: ”Kim Kardashian
West", 

numFollowers: 62104245
followers: [

“c_hotaling”,

“IAmJerdog”, 

“ChloeCondon”

...
],
has_extras: true
{
_id: ”KimKardashian_1",
twitter_id: “KimKardashian”,

is_overflow: true,
followers: [

“StephenAtHome”,

“TheEllenShow”, 

“hulu”

...
]
}
@JoeKarlsson1
Data that is accessed together should be
stored together.
@JoeKarlsson1
Storage vs Developer Costs
0
25000
50000
75000
100000
1985 2017
Storage Cost per GB
Developer Salary
Data that is accessed together should be
stored together.
@JoeKarlsson1
Data that is accessed together should be
stored together.
Don’t normalize your data for the sake of normalizing it.
{

a: “b”,
c: {

d: “e”

...

},
f: [“g”, “h”, “i”],
j: [ 

{
k: “l”
}, 

{
m: “n”
}
]
}
@JoeKarlsson1
Stop using transactions regularly.
Relying on transactions is a bad design smell.
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
@JoeKarlsson1
Stop using transactions regularly.
Relying on transactions is a bad design smell.
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
{
...
}
@JoeKarlsson1
The journey from SQL to MongoDB
@JoeKarlsson1
Row Column Table Database Index Join Join
Left Outer
Join
Recursive
Common Table
Expressions
View Transaction
Document Field Collection Database Index Embedding
Database
References
$lookup $graphLookup View Transaction
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
1. Program faster
# UPDATE THE USER'S PROFILE IN THE DATABASE
### First update what is stored in the Users table
sql = "UPDATE Users SET first_name=%s, surname=%s, cell=%s,
city=%s, location_x=%s, location_y=%s WHERE (ID=%s)"

values = (

user["first_name"], 

user["surname"], 

user["cell"], 

user["city"], 

user["location_x"], 

user["location_y"], 

userId)

mycursor.execute(sql, values)
mydb.commit()
# UPDATE THE USER'S PROFILE IN THE DATABASE
### Since the user's data is stored in a single
document, we only have to make one update
result = db['Users'].update_one(

{"_id": userId}, {"$set": user})


@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
2. Scale cheaper
1. Program faster
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3. Query faster
2. Scale cheaper
1. Program faster
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
4. Pivot easier
3. Query faster
2. Scale cheaper
1. Program faster
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3) Change your mindset in 3 key ways
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3) Change your mindset in 3 key ways
1. Not all documents in a collection need to have the same fields.
{
first_name: "Paul",
surname: "Miller",
cell: "447557505611",
city: "London",
location: [45.123,47.232],
profession: ["banking", "finance", "trader"],
cars: [
{
model: "Bentley",
year: 1973
},
{
model: "Rolls Royce",
year: 1965
}
]
}
{
first_name: ”Joe",
surname: ”Karlsson",
cell: ”1235552222",
city: ”Minneapolis”,
profession: [”software engineer", ”developer advocate"],
}
{
first_name: ”BMO",
surname: ”Karlsson",
city: ”Minneapolis",
}
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3) Change your mindset in 3 key ways
1. Not all documents in a collection need to have the same fields.
2. Data that is accessed together should be stored together.
{

a: “b”,
c: {

d: “e”

...

},
f: [“g”, “h”, “i”],
j: [ 

{
k: “l”
}, 

{
m: “n”
}
]
}
@JoeKarlsson1
The journey from SQL to MongoDB
1) Map terms & concepts from SQL to MongoDB
2) Discover the 4 humongous advantages of MongoDB
3) Change your mindset in 3 key ways
1. Not all documents in a collection need to have the same fields.
2. Data that is accessed together should be stored together.
3. Stop using transactions regularly.
{
...
} {
...
} {
...
}
{
...
} {
...
} {
...
} {
...
}
What’s next?
@JoeKarlsson1
MongoDB Community
• MongoDB University:
• university.mongodb.com

• Recommended Course:
• M001: MongoDB Basics
@JoeKarlsson1
http://bit.ly/MongoDBChicago2019
Recommended Sessions:
• A MongoDB Journey: Moving from a Relational Database to MongoDB
Atlas [Northwestern Mutual]

• 9:30am - 10:15am: Ballroom 2

• Tutorial: Practical Data Modeling for MongoDB

• 12:30pm - 2:15pm: Ballroom 3

• Tips and Tricks++ for Querying and Indexing MongoDB [MongoDB]

• 2:35pm - 3:20pm: Ballroom 5
@JoeKarlsson1
@JoeKarlsson1
Thank you!
{
name: “Joe Karlsson”,
company: “MongoDB”,
title: [
“Developer Advocate”,
“Software Engineer”
],
twitter: “@JoeKarlsson1”,
website: “joekarlsson.com”,
}
#MDBlocal
[Jumpstart] From SQL
to NoSQL - Changing
your Mindset
https://www.surveymonkey.com/r/6NS88JY
Every session you rate enters you into a
drawing for a $250 Visa gift card, sponsored by
Additional Resources
•http://bit.ly/MongoDBChicago2019
•$200 in free Atlas credits
• Advanced Schema Design Patterns (webinar)
• Building with Patterns: A Summary (blog
series)
• M320: Data Modeling (MongoDB University
Course)
@JoeKarlsson1
Additional Resources
@JoeKarlsson1
• The MongoDB Docs
• JSON Schema Validation – Locking down
your model the smart way
• JSON Schema Validation - Checking Your
Arrays
• M121: The MongoDB Aggregation Framework
MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...
MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...
MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...
 
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: TutorialMongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
 
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 .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDBMongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
 
IOOF IT System Modernisation
IOOF IT System ModernisationIOOF IT System Modernisation
IOOF IT System Modernisation
 
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQLMongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
 
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQLMongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
 
Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters
 
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 World 2019: MongoDB in Data Science: How to Build a Scalable Product ...
MongoDB World 2019: MongoDB in Data Science: How to Build a Scalable Product ...MongoDB World 2019: MongoDB in Data Science: How to Build a Scalable Product ...
MongoDB World 2019: MongoDB in Data Science: How to Build a Scalable Product ...
 
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
 
MongoDB BI Connector & Tableau
MongoDB BI Connector & Tableau MongoDB BI Connector & Tableau
MongoDB BI Connector & Tableau
 
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 Server
 
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 Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB AtlasMongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
 
FIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LDFIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LD
 
MongoDB Stich Overview
MongoDB Stich OverviewMongoDB Stich Overview
MongoDB Stich Overview
 
Query in Couchbase. N1QL: SQL for JSON
Query in Couchbase.  N1QL: SQL for JSONQuery in Couchbase.  N1QL: SQL for JSON
Query in Couchbase. N1QL: SQL for JSON
 

Similar a MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset

Similar a MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset (20)

MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...
MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...
MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...
 
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
 
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
 
MongoDB World 2019: From SQL to NoSQL -- Changing Your Mindset
MongoDB World 2019: From SQL to NoSQL -- Changing Your MindsetMongoDB World 2019: From SQL to NoSQL -- Changing Your Mindset
MongoDB World 2019: From SQL to NoSQL -- Changing Your Mindset
 
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
 
MongoDB: Back to Basics
MongoDB:  Back to BasicsMongoDB:  Back to Basics
MongoDB: Back to Basics
 
Intro to MongoDB (Extended Session)
Intro to MongoDB (Extended Session)Intro to MongoDB (Extended Session)
Intro to MongoDB (Extended Session)
 
Intro to MongoDB Workshop
Intro to MongoDB WorkshopIntro to MongoDB Workshop
Intro to MongoDB Workshop
 
MongoDB.local Dallas 2019: Building Your First MongoDB App Using Atlas & Stitch
MongoDB.local Dallas 2019: Building Your First MongoDB App Using Atlas & StitchMongoDB.local Dallas 2019: Building Your First MongoDB App Using Atlas & Stitch
MongoDB.local Dallas 2019: Building Your First MongoDB App Using Atlas & Stitch
 
MongoDB Workshop Sophia Conf 2018
MongoDB Workshop Sophia Conf 2018MongoDB Workshop Sophia Conf 2018
MongoDB Workshop Sophia Conf 2018
 
Webinar: MongoDB and Analytics: Building Solutions with the MongoDB BI Connector
Webinar: MongoDB and Analytics: Building Solutions with the MongoDB BI ConnectorWebinar: MongoDB and Analytics: Building Solutions with the MongoDB BI Connector
Webinar: MongoDB and Analytics: Building Solutions with the MongoDB BI Connector
 
Building your first MEAN application
Building your first MEAN applicationBuilding your first MEAN application
Building your first MEAN application
 
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
MongoDB Evenings DC: MongoDB - The New Default Database for Giant IdeasMongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
 
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And WhentranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
Jumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema DesignJumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema Design
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB and DigitalOcean Automation with Cloud Manager
MongoDB and DigitalOcean Automation with Cloud ManagerMongoDB and DigitalOcean Automation with Cloud Manager
MongoDB and DigitalOcean Automation with Cloud Manager
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
 

Más de MongoDB

Más de MongoDB (20)

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: 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: 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: 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 .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
 
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
 
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB ChartsMongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
 
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset

  • 1. #MDBlocal [Jumpstart] From SQL to NoSQL: Changing your Mindset @JoeKarlsson1 Joe Karlsson
  • 2. Did you know that the two main bottlenecks for web app performance are: @JoeKarlsson1Source: https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4 * Network speed * Database execution speed
  • 3. We can only control one of these things @JoeKarlsson1Source: https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
  • 5. { name: “Joe Karlsson”, company: “MongoDB”, pronouns: “He/They”, title: [ “Developer Advocate”, “Software Engineer” ], twitter: “@JoeKarlsson1”, website: “joekarlsson.com”, }
  • 8. @JoeKarlsson1 Want to watch me make stuff? https://www.twitch.tv/joe_karlsson @JoeKarlsson1
  • 10. Thank you so much for coming! @JoeKarlsson1
  • 13. How’s this talk going to work? @JoeKarlsson1
  • 14. Feel free to ask questions at anytime @JoeKarlsson1
  • 16. Get the slides/ resources on my Twitter after the talk: @JoeKarlsson1 @JoeKarlsson1
  • 19. Agenda 1.Map terms & concepts from SQL to MongoDB 2.Discover the 4 humongous advantages of MongoDB 3.Change your mindset in 3 key ways @JoeKarlsson1
  • 20. Agenda 1.Map terms & concepts from SQL to MongoDB 2.Discover the 4 humongous advantages of MongoDB 3.Change your mindset in 3 key ways @JoeKarlsson1 Row Column Table Database Index Join Join Left Outer Join Recursive Common Table Expressions View Transaction Document Field Collection Database Index Embedding Database References $lookup $graphLookup View Transaction
  • 22. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 23. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 24. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 25. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 26. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 27. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 28. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 29. @JoeKarlsson1 MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 30. @JoeKarlsson1 Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  • 31. @JoeKarlsson1 Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  • 32. @JoeKarlsson1 Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  • 33. @JoeKarlsson1 Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID user_id model year 20 1 Bentley 1973 21 1 Rolls Royce 1965 Cars ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  • 34. @JoeKarlsson1 Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID user_id model year 20 1 Bentley 1973 21 1 Rolls Royce 1965 Cars ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  • 35. @JoeKarlsson1 Collections vs Tables { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Joe", surname: ”Karlsson", cell: ”1235552222", city: ”Minneapolis”, profession: [”software engineer", ”developer advocate"], } { first_name: ”BMO", surname: ”Karlsson", city: ”Minneapolis", } UsersUsers ID first_name surname cell city location_ x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Joe Karlsson 1235552222 Minneapolis NULL NULL 3 Sydney Schaefer NULL Minneapolis NULL NULL
  • 36. @JoeKarlsson1 Collections vs Tables { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Joe", surname: ”Karlsson", cell: ”1235552222", city: ”Minneapolis”, profession: [”software engineer", ”developer advocate"], } { first_name: ”BMO", surname: ”Karlsson", city: ”Minneapolis", } UsersUsers ID first_name surname cell city location_ x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Joe Karlsson 1235552222 Minneapolis NULL NULL 3 BMO Karlsson NULL Minneapolis NULL NULL
  • 37. @JoeKarlsson1 Collections vs Tables { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Joe", surname: ”Karlsson", cell: ”1235552222", city: ”Minneapolis”, profession: [”software engineer", ”developer advocate"], } { first_name: ”BMO", surname: ”Karlsson", city: ”Minneapolis", } UsersUsers ID first_name surname cell city location_ x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Joe Karlsson 1235552222 Minneapolis NULL NULL 3 BMO Karlsson NULL Minneapolis NULL NULL
  • 38. Don’t panic! Use schema validation. Flexible schema
 database
  • 39. Document Row(s) ID a ... 1 b ... 2 ... ... 3 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... { ...
 a: “b”
 ... }
  • 40. Field ID a ... 1 b ... 2 c ... 3 ... ... { ...
 a: “b”
 ... } { ...
 a: “c”
 ... } Column
  • 41. TableCollection { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... }
  • 43. @JoeKarlsson1 So a DBA walks
 into a NoSQL bar… But immediately leaves because they couldn’t find table.
  • 45. DatabaseDatabase ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } { ... } { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
  • 46. IndexIndex { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
  • 47. ViewView { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... }
  • 48. Embedding { ...
 a: “b”,
 ... c: {
 d: “e”
 ...
 },
 ... } ID a ... 1 b ... 2 ... ... 3 ... ... ... d ... 1 e ... ... ... ... Join
  • 51. @JoeKarlsson1 Row Column Table Database Index Join Join Left Outer Join Recursive Common Table Expressions View Transaction Document Field Collection Database Index Embedding Database References $lookup $graphLookup View Transaction The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB
  • 52. Agenda 1.Map terms & concepts from SQL to MongoDB 2.Discover the 4 humongous advantages of MongoDB 3.Change your mindset in 3 key ways @JoeKarlsson1 1.Program faster 2.Pivot easier 3.Query faster 4.Scale Cheaper
  • 53. @JoeKarlsson1 Program faster! Update Your Profile Documents map to data structures in most popular languages.
  • 54. @JoeKarlsson1 Program faster! { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], } ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions
  • 55. import pymongo
 from pymongo import MongoClient # CONNECT TO THE DB client = MongoClient() client =
 pymongo.MongoClient("mongodb+srv://
 username:password@cluster0nsdia.
 mongodb.net/test?retryWrites=true") db = client.fabapp 
 # THE ID OF THE USER WHOSE PROFILE WE WILL BE RETRIEVING AND UPDATING userId = 1 Program faster! import mysql.connector 
 # CONNECT TO THE DB mydb = mysql.connector.connect(
 host="localhost",
 user=”username",
 passwd=”password",
 database=”fabapp”
 ) mycursor = mydb.cursor() 
 # THE ID OF THE USER WHOSE PROFILE WE WILL BE RETRIEVING AND UPDATING userId = 1
  • 56. # GET THE USER'S PROFILE INFORMATION ### Pull the info from the Users table & put it in the user dictionary sql = "Select * FROM Users WHERE Users.ID=%s”
 values = (userId,)
 mycursor.execute(sql, values)
 result = mycursor.fetchone() user = {
 "first_name": result[1],
 "surname": result[2],
 "cell": result[3],
 "city": result[4],
 "location_x": result[5],
 "location_y": result[6]
 } # GET THE USER'S PROFILE INFORMATION ## We can pull all of the info from the same document since we used embedding user = db['Users'].find_one({"_id": userId}) Program faster! ### Pull the info from the Professions table & put it in the user dictionary sql = "Select * FROM Professions WHERE
 Professions.user_id=%s”
 values = (userId,)
 mycursor.execute(sql, values)
 results = mycursor.fetchall() professions = []
 for result in results:
 professions.append(result[2])
 user["professions"] = professions
  • 57. # UPDATE THE USER DICTIONARY BASED ON USER INPUT IN THE APP ### We'll update the user dictionary manually for simplicity user = {
 "first_name": "NewFirst",
 "surname": "NewSurname",
 "cell": "123-456-7890",
 "city": "NewCity",
 "location": [40.762, -73.979],
 "professions": [”Manager", "Engineer"]
 } Program faster! # UPDATE THE USER DICTIONARY BASED ON USER INPUT IN THE APP ### We'll update the user dictionary manually for simplicity user = {
 "first_name": "NewFirst",
 "surname": "NewSurname",
 "cell": "123-456-7890",
 "city": "NewCity",
 "location_x": 40.762, 
 "location_y": 73.979,
 "professions": [”Manager", "Engineer"]
 }
  • 58. # UPDATE THE USER'S PROFILE IN THE DATABASE ### First update what is stored in the Users table sql = "UPDATE Users SET first_name=%s, surname=%s, cell=%s, city=%s, location_x=%s, location_y=%s WHERE (ID=%s)"
 values = (
 user["first_name"], 
 user["surname"], 
 user["cell"], 
 user["city"], 
 user["location_x"], 
 user["location_y"], 
 userId)
 mycursor.execute(sql, values) mydb.commit() # UPDATE THE USER'S PROFILE IN THE DATABASE ### Since the user's data is stored in a single document, we only have to make one update result = db['Users'].update_one(
 {"_id": userId}, {"$set": user}) 
 Program faster! ### Delete existing records in Professions table and add new ones sql = "DELETE FROM Professions WHERE user_id=%s”
 values = (userId,)
 mycursor.execute(sql, values)
 mydb.commit() if(len(user["professions"]) > 0):
 sql = "INSERT INTO Professions 
 (user_id,profession) VALUES (%s, %s)”
 values = []
 for profession in user["professions"]:
 values.append((userId, profession))
 mycursor.executemany(sql,values)
 mydb.commit()
  • 59. 30 lines of code Program faster! 73 lines of code
  • 60. @JoeKarlsson1 Pivot easier! Easily change the shape of your data as your app evolves. SQLMongoDB {
 a: “b”,
 c: “one”,
 e: “f” } {
 a: “b”,
 c: 1,
 new: “no biggee” } ALTER TABLE `mydb`.`letters_table` DROP COLUMN `e`, ADD COLUMN `New` VARCHAR(45) NULL AFTER `C`, CHANGE COLUMN `C` `C` INT NULL DEFAULT NULL ;
  • 61. @JoeKarlsson1 Query faster! Stop doing expensive joins to get your data. SQLMongoDB ID a ... 1 b ... 2 ... ... 3 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... { ...
 a: “b”,
 ... c: {
 d: “e”
 ...
 },
 ... }
  • 62. @JoeKarlsson1 Scale cheaper! As the size of your server grows, scale horizontally.
  • 63. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB
  • 64. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 1. Program faster # UPDATE THE USER'S PROFILE IN THE DATABASE ### First update what is stored in the Users table sql = "UPDATE Users SET first_name=%s, surname=%s, cell=%s, city=%s, location_x=%s, location_y=%s WHERE (ID=%s)"
 values = (
 user["first_name"], 
 user["surname"], 
 user["cell"], 
 user["city"], 
 user["location_x"], 
 user["location_y"], 
 userId)
 mycursor.execute(sql, values) mydb.commit() # UPDATE THE USER'S PROFILE IN THE DATABASE ### Since the user's data is stored in a single document, we only have to make one update result = db['Users'].update_one(
 {"_id": userId}, {"$set": user}) 

  • 65. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 2. Scale cheaper 1. Program faster
  • 66. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3. Query faster 2. Scale cheaper 1. Program faster
  • 67. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 4. Pivot easier 3. Query faster 2. Scale cheaper 1. Program faster
  • 68. Agenda 1.Map terms & concepts from SQL to MongoDB 2.Discover the 4 humongous advantages of MongoDB 3.Change your mindset in 3 key ways @JoeKarlsson1 1.Not all documents in a collection need to have the same fields. 2.Data that is accessed together should be stored together. 3.Stop using transactions regularly.
  • 69. @JoeKarlsson1 Not all documents in a collection need to have the same fields.
  • 70. @JoeKarlsson1 Not all documents in a collection need to have the same fields. The Polymorphic Pattern { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Joe", surname: ”Karlsson", cell: ”1235552222", city: ”Minneapolis”, profession: [”software engineer", ”developer advocate"], } { first_name: ”BMO", surname: ”Karlsson", city: ”Minneapolis", }
  • 71. @JoeKarlsson1 Not all documents in a collection need to have the same fields. The Outlier Pattern { _id: ”JoeKarlsson1", displayName: ”JoeKarlsson1”, 
 numFollowers: 2095 followers: [
 “jessicaewest”,
 “wesley83”, 
 “GraceFr”
 ... ] } { _id: ”KimKardashian", displayName: ”Kim Kardashian West", 
 numFollowers: 62104245 followers: [
 “c_hotaling”,
 “IAmJerdog”, 
 “ChloeCondon”
 ... ], has_extras: true { _id: ”KimKardashian_1", twitter_id: “KimKardashian”,
 is_overflow: true, followers: [
 “StephenAtHome”,
 “TheEllenShow”, 
 “hulu”
 ... ] }
  • 72. @JoeKarlsson1 Data that is accessed together should be stored together.
  • 73. @JoeKarlsson1 Storage vs Developer Costs 0 25000 50000 75000 100000 1985 2017 Storage Cost per GB Developer Salary Data that is accessed together should be stored together.
  • 74. @JoeKarlsson1 Data that is accessed together should be stored together. Don’t normalize your data for the sake of normalizing it. {
 a: “b”, c: {
 d: “e”
 ...
 }, f: [“g”, “h”, “i”], j: [ 
 { k: “l” }, 
 { m: “n” } ] }
  • 75. @JoeKarlsson1 Stop using transactions regularly. Relying on transactions is a bad design smell. { ... } { ... } { ... } { ... } { ... } { ... } { ... }
  • 76. @JoeKarlsson1 Stop using transactions regularly. Relying on transactions is a bad design smell. { ... } { ... } { ... } { ... } { ... } { ... } { ... }
  • 78. @JoeKarlsson1 Row Column Table Database Index Join Join Left Outer Join Recursive Common Table Expressions View Transaction Document Field Collection Database Index Embedding Database References $lookup $graphLookup View Transaction The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB
  • 79. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB
  • 80. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 1. Program faster # UPDATE THE USER'S PROFILE IN THE DATABASE ### First update what is stored in the Users table sql = "UPDATE Users SET first_name=%s, surname=%s, cell=%s, city=%s, location_x=%s, location_y=%s WHERE (ID=%s)"
 values = (
 user["first_name"], 
 user["surname"], 
 user["cell"], 
 user["city"], 
 user["location_x"], 
 user["location_y"], 
 userId)
 mycursor.execute(sql, values) mydb.commit() # UPDATE THE USER'S PROFILE IN THE DATABASE ### Since the user's data is stored in a single document, we only have to make one update result = db['Users'].update_one(
 {"_id": userId}, {"$set": user}) 

  • 81. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 2. Scale cheaper 1. Program faster
  • 82. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3. Query faster 2. Scale cheaper 1. Program faster
  • 83. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 4. Pivot easier 3. Query faster 2. Scale cheaper 1. Program faster
  • 84. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3) Change your mindset in 3 key ways
  • 85. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3) Change your mindset in 3 key ways 1. Not all documents in a collection need to have the same fields. { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Joe", surname: ”Karlsson", cell: ”1235552222", city: ”Minneapolis”, profession: [”software engineer", ”developer advocate"], } { first_name: ”BMO", surname: ”Karlsson", city: ”Minneapolis", }
  • 86. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3) Change your mindset in 3 key ways 1. Not all documents in a collection need to have the same fields. 2. Data that is accessed together should be stored together. {
 a: “b”, c: {
 d: “e”
 ...
 }, f: [“g”, “h”, “i”], j: [ 
 { k: “l” }, 
 { m: “n” } ] }
  • 87. @JoeKarlsson1 The journey from SQL to MongoDB 1) Map terms & concepts from SQL to MongoDB 2) Discover the 4 humongous advantages of MongoDB 3) Change your mindset in 3 key ways 1. Not all documents in a collection need to have the same fields. 2. Data that is accessed together should be stored together. 3. Stop using transactions regularly. { ... } { ... } { ... } { ... } { ... } { ... } { ... }
  • 89. MongoDB Community • MongoDB University: • university.mongodb.com
 • Recommended Course: • M001: MongoDB Basics @JoeKarlsson1
  • 91. Recommended Sessions: • A MongoDB Journey: Moving from a Relational Database to MongoDB Atlas [Northwestern Mutual] • 9:30am - 10:15am: Ballroom 2 • Tutorial: Practical Data Modeling for MongoDB • 12:30pm - 2:15pm: Ballroom 3 • Tips and Tricks++ for Querying and Indexing MongoDB [MongoDB] • 2:35pm - 3:20pm: Ballroom 5 @JoeKarlsson1
  • 93. { name: “Joe Karlsson”, company: “MongoDB”, title: [ “Developer Advocate”, “Software Engineer” ], twitter: “@JoeKarlsson1”, website: “joekarlsson.com”, }
  • 94. #MDBlocal [Jumpstart] From SQL to NoSQL - Changing your Mindset https://www.surveymonkey.com/r/6NS88JY Every session you rate enters you into a drawing for a $250 Visa gift card, sponsored by
  • 95. Additional Resources •http://bit.ly/MongoDBChicago2019 •$200 in free Atlas credits • Advanced Schema Design Patterns (webinar) • Building with Patterns: A Summary (blog series) • M320: Data Modeling (MongoDB University Course) @JoeKarlsson1
  • 96. Additional Resources @JoeKarlsson1 • The MongoDB Docs • JSON Schema Validation – Locking down your model the smart way • JSON Schema Validation - Checking Your Arrays • M121: The MongoDB Aggregation Framework