SlideShare a Scribd company logo
1 of 52
@SoftShakeEvent 
DROP TABLE ! 
Overview of Document Design 
Tugdual Grall 
Technical Evangelist 
MongoDB 
@tgrall Soft Shake ‘14
{“about” : “me”} 
Tugdual “Tug” Grall 
• MongoDB 
Join me at the Gōng-fu I/O 
• Technical Evangelist 
• Couchbase 
• Technical Evangelist 
• eXo 
• CTO 
• Oracle 
• Developer/Product Manager 
• Mainly Java/SOA 
• Developer in consulting firms 
• Web 
• @tgrall 
• http://blog.grallandco.com 
• tgrall 
• NantesJUG co-founder 
• Pet Project : 
• http://www.resultri.com 
• tug@mongodb.com 
• tugdual@gmail.com
With “Relations” Between Rows 
Customer 
ID First 
Name Last 
Name City 
0 John Doe New 
York 
1 Mark Smith San 
Francisco 
2 Jay Black Newark 
3 Meagan White London 
4 Edward Daniels Boston 
Account 
Number Branch 
ID Account 
Type Customer 
ID 
10 100 Checking 0 
11 101 Savings 0 
12 101 IRA 0 
13 200 Checking 1 
14 200 Savings 1 
15 201 IRA 2
But, some things are hard to model 
• Let’s look at a product catalog:
Baseball Bat 
! 
-3 length to weight ratio 
2-5/8" barrel diameter 
Two-piece construction 
R2 alloy barrel provides outstanding durability, performance and "pop" 
R2 composite handle shifts weight into the bat's knob for ultra-fast swing speeds 
Rifle Barrel design removes weight from the barrel for thinner wall thickness 
Acoustic barrel offers that sweet-sounding "ping" 
Contact grip helps eliminate sting and vibration 
AIR Elite is RIP-IT's® fastest BBCOR bat and the one with the most performance 
BBCOR certified - approved for high school and collegiate play 
Includes RIP-IT's® "Love It Or Return It" 30 Day Refund Policy with free return shipping 
Manufacturer's warranty: 400 days 
Made in the USA 
Model: B1403E
Bat Product Table 
Category Model Name Brand 
Length to 
weight 
ratio 
Barrel 
Dia Type Barrel Handle Cert. Country Price 
Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy 
R2 
composite BBCOR USA $399.99 
Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 
Bat MCB1B One Marucci -3 2 5/8 One-piece 
AZ3000 
aluminum 
AZ3000 
aluminum BBCOR Imported $199.99 
Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX 
SIC Black 
Carbon BBCOR China $399.99
Lets Add Gloves 
Size: 12" 
Infield/Outfield/Pitcher model 
2-Piece Web pattern 
Most popular MLB® pattern among pitchers 
Pro Stock® American steerhide leather offers rugged durability and a superior feel 
Dual-Welting™ on "exposed edges" of the fingers helps maintain pocket shape and durability 
Pro Stock™ hand-designed pattern for unbeatable craftsmanship 
Dri-Lex® ultra-breathable wrist lining repels moisture from your hand 
Black leather with rich brown embellishments 
Pattern: B212 
Model: WTA2000BBB212 
Wilson
Bat and Glove Product Table 
Category Model Name Brand 
Length to 
weight 
ratio 
Barrel Dia Type Barrel Handle Cert. Country Price 
Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy 
R2 
composite BBCOR USA $399.99 
Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 
Bat MCB1B One Marucci -3 2 5/8 One-piece AL AL BBCOR Imported $199.99 
Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX 
SIC Black 
Carbon BBCOR China $399.99 
Category Model Name Brand Size Position Pattern Web 
Pattern 
Material Color Country Price 
Glove 
WTA2000B 
BB212 A2000 Wilson 12" Infield B212 2-piece Leather black Vietnam $299.99 
Glove PRO112PT HOH Pro Rawlings 11.25" Outfield Pro taper 
Modified 
Trap-Eze 
Horween 
Leather black China $229.99
Add some baseballs 
Cover: Full grain leather for excellent durability 
Core: Cushioned cork core 
Additions/Technologies: Made to the exact specifications of MLB 
Stitching/Seams: 108 classic red stitches/Rawlings® Major League seaming 
League/Certification(s): MLB 
Balls included per purchase: individual 
Recommended Age: All ages 
Model : ROMLB 
Rawlings
Bat and Glove and Ball Product Table 
Category Model Name Brand 
Length to 
weight 
ratio 
Barrel 
Dia Type Barrel Handle Cert. Country Price 
Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy R2 composite BBCOR USA $399.99 
Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 
Bat MCB1B One Marucci -3 2 5/8 One-piece AL AL BBCOR Imported $199.99 
Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX 
SIC Black 
Carbon BBCOR China $399.99 
Categor 
y 
Model Name Brand Size Position Pattern Web 
Pattern 
Material Color Country Price 
Glove 
WTA200 
0BBB21 
2 
A2000 Wilson 12" Infield B212 2-piece Leather black Vietnam $299.99 
Glove 
PRO112 
PT HOH Pro 
Rawling 
s 11.25" Outfield 
Pro 
taper 
Modifie 
d Trap- 
Eze 
Horwee 
n 
Leather 
black China $229.99 
Category Model Name Brand Color Cover Core Cert. Country Price 
Baseball 
DICRLLB1 
PBG 
Little 
League Rawlings white Leather 
Cork 
rubber 
Little 
League China $4.99 
Baseball ROML MLB Rawlings white Leather cork China $6.99
Sparse Table 
Category Model Name Brand 
Length to 
weight 
ratio 
Barrel Dia Type Barrel Handle Certificati 
on 
Country Price Size Position Pattern Web 
Pattern 
Material Color Cover Core 
Bat B1403E Air 
Elite RIP-­‐IT -­‐3 2 
5/8 Composite R2 
Alloy 
R2 
composite BBCOR USA $399.99 
Bat B1403 Prototype RIP-­‐IT -­‐3 2 
5/8 One-­‐piece R1 
Alloy R1 
Alloy BBCOR USA $199.99 
Bat MCB1B One Marucci -­‐3 2 
5/8 One-­‐piece 
AZ3000 
aluminum 
AZ3000 
aluminum BBCOR Imported $199.99 
Bat BB14S1 S1 Easton -­‐3 2 
5/8 Composite IMX 
SIC 
Black 
Carbon BBCOR China $399.99 
Glove 
WTA2000BB 
B212 A2000 Wilson Vietnam $299.99 
12" Infield B212 2-­‐piece Leather black 
Glove PRO112PT HOH 
Pro Rawlings China $229.99 
11.25" Outfield Pro 
taper 
Modified 
Trap-­‐Eze 
Horween 
Leather black 
Baseball 
DICRLLB1PB 
G Little 
League Rawlings Little 
League China $4.99 
white Leather 
cork 
and 
rubber 
Baseball ROML MLB Rawlings China $6.99 
white Leather cork 
Continue adding columns as you add new products
Maybe this design will work better 
prodID property value 
1 length/ 
weight 
-3 
1 barrel dia 2 5/8 
1 type composite 
1 certification BBCOR 
… 
5 size 12 
5 position infield 
5 pattern B212 
5 material leather 
5 color black 
… 
8 color white 
8 cover leather 
8 core cork 
prodID Category Model Name Brand Country Price 
1 Bat B1403E Air Elite RIP-IT USA $399.99 
2 Bat B1403 Prototype RIP-IT USA $199.99 
3 Bat MCB1B One Marucci Imported $199.99 
4 Bat BB14S1 S1 Easton China $399.99 
5 Glove 
WTA2000B 
BB212 A2000 Wilson Vietnam $299.99 
6 Glove PRO112PT HOH Pro Rawlings China $229.99 
DICRLLB1 
7 Baseball 
PBG 
Little 
League Rawlings China $4.99 
8 Baseball ROML MLB Rawlings China $6.99
It is hard to iterate 
New Column 
Name Age Phone Email 
New Table 
New Table 
New Column
Have to Manage Changes in 3 Places 
Code XML Config DB Schema 
Relational Database 
Object Relational 
Application Mapping
Working with Documents
Match the Data in your Application 
Relational MongoDB 
{ 
first_name: ‘Paul’, 
surname: ‘Miller’ 
city: ‘London’, 
location: [45.123,47.232], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000}, 
{ model: ‘Rolls Royce’, 
year: 1965,! 
value: 330000}! 
} 
}
Let’s go back to our product catalog
How would we model this in 
MongoDB? 
Size: 12" 
Infield/Outfield/Pitcher model 
2-Piece Web pattern 
Most popular MLB® pattern among pitchers 
Pro Stock® American steerhide leather offers rugged durability and a superior feel 
Dual-Welting™ on "exposed edges" of the fingers helps maintain pocket shape and durability 
Pro Stock™ hand-designed pattern for unbeatable craftsmanship 
Dri-Lex® ultra-breathable wrist lining repels moisture from your hand 
Black leather with rich brown embellishments 
Pattern: B212 
Model: WTA2000BBB212 
Wilson
We use a document 
! 
{ 
category: “glove”, 
model: “PRO112PT”, 
name: “Air Elite”, 
brand: “Rawlings”, 
price: 229.99, 
available: Date(“2013-03-31”) 
} 
Fields 
Values 
Field values are 
typed 
string 
number 
date
Documents are rich structures 
! 
{ 
category: “glove”, 
model: “PRO112PT”, 
name: “Air Elite”, 
brand: “Rawlings”, 
price: 229.99, 
available: Date(“2013-03-31”), 
position: [“infield”, “outfield”, “pitcher”] 
} 
Fields can contain arrays
Documents are rich structures 
! 
{ 
category: “glove”, 
model: “PRO112PT”, 
name: “Air Elite”, 
brand: “Rawlings”, 
price: 229.99, 
available: Date(“2013-03-31”), 
position: [“infield”, “outfield”, “pitcher”], 
endorsed: {name: “Ryan Howard”, 
team: “Phillies”, 
position: “first base”}, 
} 
Fields can contain 
sub-documents
` 
{ 
category: “glove”, 
model: “PRO112PT”, 
name: “Air Elite”, 
brand: “Rawlings”, 
price: 229.99, 
available: Date(“2013-03-31”), 
position: [“infield”, “outfield”, “pitcher”], 
endorsed: {name: “Ryan Howard”, 
team: “Phillies”, 
position: “first base”}, 
history: [{date: Date(“2013-03-31”), price: 279.99}, 
{date: Date(“2013-06-01”), price: 259.79}, 
{date: Date(“2013-08-15”), price: 229.99}] 
} 
Fields can contain 
an array of sub-documents
Variation is easy with document model 
{ 
category: bat, 
model: B1403E, 
name: Air Elite, 
brand: “Rip-IT”, 
price: 399.99 
! 
diameter: “2 5/8”, 
barrel: R2 Alloy, 
handle: R2 Composite, 
type: composite, 
} 
! 
{ 
category: glove, 
model: PRO112PT, 
name: Air Elite, 
brand: “Rawlings”, 
price: “229.99” 
! 
size: 11.25, 
position: outfield, 
pattern: “Pro taper”, 
material: leather, 
color: black 
} 
{ 
category: ball, 
model: ROML, 
name: MLB, 
brand: “Rawlings”, 
price: “6.99” 
! 
cover: leather, 
core: cork, 
color: white 
}
Relational Schema Design 
Focus on data storage
Document Schema Design 
Focus on data use
Document Design
Schema Design Considerations 
• How do we manipulate the data? 
– Dynamic Ad-Hoc Queries 
– Atomic Updates 
– Aggregation 
• What are the access patterns of the application? 
– Read/Write Ratio 
– Types of Queries / Updates 
– Data life-cycle and growth rate
Let's model something together 
How about a business card?
Business Card
Referencing 
Addresses! 
! 
{! 
! “_id”: 1,! 
! “street”: “10260 Bandley Dr”,! 
! 
“city”: “Cupertino”,! 
! “state”: “CA”,! 
! “zip_code”: ”95014”,! 
! “country”: “USA”! 
} 
Contacts! 
! 
{! 
“_id”: 2,! 
“name”: “Steven Jobs”,! 
“title”: “VP, New Product Development”,“company”: “Apple Computer”,! 
“phone”: “408-996-1010”,! 
“address_id”: 1! 
}
Embedding 
Contacts! 
! 
{! 
“_id”: 2,! 
“name”: “Steven Jobs”,! 
“title”: “VP, New Product Development”,! 
“company”: “Apple Computer”,! 
“address”: {! 
! “street”: “10260 Bandley Dr”,! 
! “city”: “Cupertino”,! 
! “state”: “CA”,! 
! “zip_code”: ”95014”,! 
! “country”: “USA”! 
},! 
“phone”: “408-996-1010”! 
}!
! 
Contact 
Relational Schema 
! 
• name 
• company 
• title 
• phone 
Address 
! 
• street 
• city 
• state 
• zip_code
! 
Contact 
! 
• name 
• company 
• adress 
address 
• Street 
street 
• City 
city 
• State 
• Zip 
zip_code 
• title 
• phone 
Document Schema
Schema Flexibility 
{! 
“name”: “Steven Jobs”,! 
“title”: “VP, New Product Development”,! 
“company”: “Apple Computer”,! 
“address”: {! 
! “street”: “10260 Bandley Dr”,! 
! “city”: “Cupertino”,! 
! “state”: “CA”,! 
! “zip_code”: ”95014”! 
},! 
“phone”: “408-996-1010”! 
}! 
{! 
“name”: “Larry Page”,! 
“url”: “http://google.com/”,! 
“title”: “CEO”,! 
“company”: “Google!”,! 
“email”: “larry@google.com”,! 
“address”: {! 
“street”: “555 Bryant, #106”,! 
“city”: “Palo Alto”,! 
“state”: “CA”,! 
“zip_code”: “94301”! 
}! 
“phone”: “650-618-1499”,! 
“fax”: “650-330-0100”! 
}
Example
Let’s Look at an 
Address Book
Groups 
N 
N 
! 
• name 
Contacts 
• name 
• company 
• title 
Addresses 
• type 
• street 
• city 
• state 
• zip_code 
Phones 
• type 
• number 
Emails 
• type 
• address 
Twitters 
• name 
• location 
• web 
• bio 
Thumbnails 
• mime_type 
• data 
Portraits 
• mime_type 
• data 
N 
1 
1 
1 
1 1 
1 
1 
1 
N 
N 
1 
Address Book Entity-Relationship
Associating Entities
! 
Contacts 
• name 
• company 
• title 
One to One 
Addresses 
• type 
• street 
• city 
• state 
• zip_code 
Phones 
• type 
• number 
Emails 
• type 
• address 
Thumbnails 
• mime_type 
• data 
Portraits 
• mime_type 
• data 
Groups 
• name 
N 
1 
N 
1 
N 
N 
N 
1 
1 
1 
1 1 
Twitters 
• name 
• location 
• web 
• bio 
1 
1
One to One 
General Recommendation 
• Full contact info all at once 
– Contact embeds twitter 
• Parent-child relationship 
– “contains” 
• twitter 
twitter 1 
• No additional data duplication 
• Can query or index on embedded field 
– e.g., “twitter.name” 
– Exceptional cases… 
Contact 
• Reference portrait which has very large data
! 
Contacts 
• name 
• company 
• title 
One to Many 
Addresses 
• type 
• street 
• city 
• state 
• zip_code 
Phones 
• type 
• number 
Emails 
• type 
• address 
Thumbnails 
• mime_type 
• data 
Portraits 
• mime_type 
• data 
Groups 
• name 
N 
1 
N 
1 
N 
N 
N 
1 
1 
1 
1 1 
Twitters 
• name 
• location 
• web 
• bio 
1 
1
One to Many 
General Recommendation 
• Full contact info all at once 
– Contact embeds multiple phones 
• Parent-children relationship 
– “contains” 
• No additional data duplication 
• Can query or index on any field 
– e.g., { “phones.type”: “mobile” } 
– Exceptional cases… 
Contact 
• phones 
phone N 
• Scaling: maximum document size is 16MB
! 
Contacts 
• name 
• company 
• title 
Many to Many 
Addresses 
• type 
• street 
• city 
• state 
• zip_code 
Phones 
• type 
• number 
Emails 
• type 
• address 
Thumbnails 
• mime_type 
• data 
Portraits 
• mime_type 
• data 
Groups 
• name 
N 
1 
N 
1 
N 
N 
N 
1 
1 
1 
1 1 
Twitters 
• name 
• location 
• web 
• bio 
1 
1
Many to Many 
Traditional Relational Association 
X 
Join table 
! 
Contacts 
• name 
• company 
• title 
• phone 
Groups 
• name 
GroupContacts 
• group_id 
• contact_id 
Use arrays instead
Many to Many 
General Recommendation 
• Depends on use case 
1. Simple address book 
• Contact references groups 
2. Corporate email groups 
group contact 
N N • group_ids: [ ] 
• Group embeds contacts for performance 
• Exceptional cases 
– Scaling: maximum document size is 16MB 
– Scaling may affect performance and working set
Contacts 
• name 
• company 
• title 
addresses 
• type 
• street 
• city 
• state 
• zip_code 
phones 
• type 
• number 
emails 
• type 
• address 
thumbnail 
• mime_type 
• data 
Groups 
• name 
N 
Portraits 
• mime_type 
• data 
N 
1 
1 
twitter 
• name 
• location 
• web 
• bio 
N 
N 
N 
1 
1 
Document model - holistic and efficient representation
Contact document example 
{! 
! “name” : “Gary J. Murakami, Ph.D.”,! 
! “company” : “MongoDB, Inc.”,! 
! “title” : “Lead Engineer”,! 
! “twitter” : {! 
! ! “name” : “Gary Murakami”, “location” : “New Providence, NJ”,! 
! ! “web” : “http://www.nobell.org”! 
! },! 
! “portrait_id” : 1,! 
! “addresses” : [ ! 
! ! { “type” : “work”, “street” : ”229 W 43rd St.”, “city” : “New York”, “zip_code” : “10036” }! 
! ],! 
! “phones” : [ ! 
! ! { “type” : “work”, “number” : “1-866-237-8815 x8015” }! 
! ],! 
! “emails” : [ ! 
! ! { “type” : “work”, “address” : “gary.murakami@mongodb.com” },! 
! ! { “type” : “home”, “address” : “gjm@nobell.org” }! 
! ]! ! 
}!
General Recommendations
Legacy Migration 
1. Copy existing schema & some data to MongoDB 
2. Iterate schema design development 
Measure performance, find bottlenecks, and embed 
1. one to one associations first 
2. one to many associations next 
3. many to many associations 
3. Migrate full dataset to new schema 
New Software Application? Embed by default
Embedding over Referencing 
• Embedding is a bit like pre-joined data 
– BSON (Binary JSON) document ops are easy for the server 
• Embed (90/10 following rule of thumb) 
– When the “one” or “many” objects are viewed in the context of 
their parent 
– For performance 
– For atomicity 
• Reference 
– When you need more scaling 
– For easy consistency with “many to many” associations without 
duplicated data
It’s All About Your Application 
• Programs+Databases = (Big) Data Applications 
• Your schema is the impedance matcher 
– Design choices: normalize/denormalize, reference/embed 
– Melds programming with MongoDB for best of both 
– Flexible for development and change 
• Programs×MongoDB = Great Big Data Applications
@SoftShakeEvent 
Thank You! 
Tugdual Grall 
Technical Evangelist 
MongoDB 
@tgrall Soft Shake ‘14

More Related Content

Similar to Drop your table ! MongoDB Schema Design

Marathon ma dnx300 flight road case
Marathon ma dnx300 flight road caseMarathon ma dnx300 flight road case
Marathon ma dnx300 flight road caseAughyeresskimu
 
Catálogo Buck 2021
Catálogo Buck 2021Catálogo Buck 2021
Catálogo Buck 2021Esteller
 
Thomson Linear RoundRail 1BC Specs
Thomson Linear RoundRail 1BC SpecsThomson Linear RoundRail 1BC Specs
Thomson Linear RoundRail 1BC SpecsElectromate
 
Thomson roundrail 1_bc_specsheet
Thomson roundrail 1_bc_specsheetThomson roundrail 1_bc_specsheet
Thomson roundrail 1_bc_specsheetElectromate
 
KOŠARKARSKI MINI KOŠ SKLZ
KOŠARKARSKI MINI KOŠ SKLZKOŠARKARSKI MINI KOŠ SKLZ
KOŠARKARSKI MINI KOŠ SKLZŽan Sklz
 
Tiger skates 2018 2019 colletion
Tiger skates 2018 2019 colletionTiger skates 2018 2019 colletion
Tiger skates 2018 2019 colletionJackson Zheng
 
2016 Catalogue track and field 160318
2016 Catalogue track and field 1603182016 Catalogue track and field 160318
2016 Catalogue track and field 160318George Chao (Sport)
 
Padia enterprise iko bearing catalogue compressed
Padia enterprise iko bearing catalogue compressedPadia enterprise iko bearing catalogue compressed
Padia enterprise iko bearing catalogue compressedIKObearingPadiaEnter
 
Thomson roundrail 1_bb_specsheet
Thomson roundrail 1_bb_specsheetThomson roundrail 1_bb_specsheet
Thomson roundrail 1_bb_specsheetElectromate
 
Thomson Linear RoundRail 1BB Specs
Thomson Linear RoundRail 1BB SpecsThomson Linear RoundRail 1BB Specs
Thomson Linear RoundRail 1BB SpecsElectromate
 
Custom dresser layout plans
Custom dresser layout plansCustom dresser layout plans
Custom dresser layout plansMiguel Zamarripa
 
MegaDome DESIGN GUIDE 2015 V2
MegaDome DESIGN GUIDE 2015 V2MegaDome DESIGN GUIDE 2015 V2
MegaDome DESIGN GUIDE 2015 V2Colin Timms
 

Similar to Drop your table ! MongoDB Schema Design (18)

Marathon ma dnx300 flight road case
Marathon ma dnx300 flight road caseMarathon ma dnx300 flight road case
Marathon ma dnx300 flight road case
 
PAKA Custom Pro-Match Soccer Balls
PAKA Custom Pro-Match Soccer BallsPAKA Custom Pro-Match Soccer Balls
PAKA Custom Pro-Match Soccer Balls
 
Catálogo Buck 2021
Catálogo Buck 2021Catálogo Buck 2021
Catálogo Buck 2021
 
Thomson Linear RoundRail 1BC Specs
Thomson Linear RoundRail 1BC SpecsThomson Linear RoundRail 1BC Specs
Thomson Linear RoundRail 1BC Specs
 
Thomson roundrail 1_bc_specsheet
Thomson roundrail 1_bc_specsheetThomson roundrail 1_bc_specsheet
Thomson roundrail 1_bc_specsheet
 
KOŠARKARSKI MINI KOŠ SKLZ
KOŠARKARSKI MINI KOŠ SKLZKOŠARKARSKI MINI KOŠ SKLZ
KOŠARKARSKI MINI KOŠ SKLZ
 
Airfoil
AirfoilAirfoil
Airfoil
 
Tiger skates 2018 2019 colletion
Tiger skates 2018 2019 colletionTiger skates 2018 2019 colletion
Tiger skates 2018 2019 colletion
 
1. case study
1. case study1. case study
1. case study
 
2016 Catalogue track and field 160318
2016 Catalogue track and field 1603182016 Catalogue track and field 160318
2016 Catalogue track and field 160318
 
2016 Catalogue track and field
2016 Catalogue track and field2016 Catalogue track and field
2016 Catalogue track and field
 
Padia enterprise iko bearing catalogue compressed
Padia enterprise iko bearing catalogue compressedPadia enterprise iko bearing catalogue compressed
Padia enterprise iko bearing catalogue compressed
 
Thomson roundrail 1_bb_specsheet
Thomson roundrail 1_bb_specsheetThomson roundrail 1_bb_specsheet
Thomson roundrail 1_bb_specsheet
 
Thomson Linear RoundRail 1BB Specs
Thomson Linear RoundRail 1BB SpecsThomson Linear RoundRail 1BB Specs
Thomson Linear RoundRail 1BB Specs
 
Custom dresser layout plans
Custom dresser layout plansCustom dresser layout plans
Custom dresser layout plans
 
Occidental Leather Catalog
Occidental Leather CatalogOccidental Leather Catalog
Occidental Leather Catalog
 
FRP & FIBER PRODUCTS By US Fibre Industries
FRP & FIBER PRODUCTS By US Fibre IndustriesFRP & FIBER PRODUCTS By US Fibre Industries
FRP & FIBER PRODUCTS By US Fibre Industries
 
MegaDome DESIGN GUIDE 2015 V2
MegaDome DESIGN GUIDE 2015 V2MegaDome DESIGN GUIDE 2015 V2
MegaDome DESIGN GUIDE 2015 V2
 

More from Tugdual Grall

Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkTugdual Grall
 
Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkTugdual Grall
 
Fast Cars, Big Data - How Streaming Can Help Formula 1
Fast Cars, Big Data - How Streaming Can Help Formula 1Fast Cars, Big Data - How Streaming Can Help Formula 1
Fast Cars, Big Data - How Streaming Can Help Formula 1Tugdual Grall
 
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!Tugdual Grall
 
Proud to be Polyglot - Riviera Dev 2015
Proud to be Polyglot - Riviera Dev 2015Proud to be Polyglot - Riviera Dev 2015
Proud to be Polyglot - Riviera Dev 2015Tugdual Grall
 
Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications Tugdual Grall
 
Proud to be polyglot
Proud to be polyglotProud to be polyglot
Proud to be polyglotTugdual Grall
 
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6Tugdual Grall
 
Some cool features of MongoDB
Some cool features of MongoDBSome cool features of MongoDB
Some cool features of MongoDBTugdual Grall
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB ApplicationTugdual Grall
 
Opensourceday 2014-iot
Opensourceday 2014-iotOpensourceday 2014-iot
Opensourceday 2014-iotTugdual Grall
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseTugdual Grall
 
Introduction to NoSQL with Couchbase
Introduction to NoSQL with CouchbaseIntroduction to NoSQL with Couchbase
Introduction to NoSQL with CouchbaseTugdual Grall
 
Why and How to integrate Hadoop and NoSQL?
Why and How to integrate Hadoop and NoSQL?Why and How to integrate Hadoop and NoSQL?
Why and How to integrate Hadoop and NoSQL?Tugdual Grall
 
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0Tugdual Grall
 
Big Data Paris : Hadoop and NoSQL
Big Data Paris : Hadoop and NoSQLBig Data Paris : Hadoop and NoSQL
Big Data Paris : Hadoop and NoSQLTugdual Grall
 
Big Data Israel Meetup : Couchbase and Big Data
Big Data Israel Meetup : Couchbase and Big DataBig Data Israel Meetup : Couchbase and Big Data
Big Data Israel Meetup : Couchbase and Big DataTugdual Grall
 

More from Tugdual Grall (20)

Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache Flink
 
Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache Flink
 
Fast Cars, Big Data - How Streaming Can Help Formula 1
Fast Cars, Big Data - How Streaming Can Help Formula 1Fast Cars, Big Data - How Streaming Can Help Formula 1
Fast Cars, Big Data - How Streaming Can Help Formula 1
 
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!
Lambda Architecture: The Best Way to Build Scalable and Reliable Applications!
 
Big Data Journey
Big Data JourneyBig Data Journey
Big Data Journey
 
Proud to be Polyglot - Riviera Dev 2015
Proud to be Polyglot - Riviera Dev 2015Proud to be Polyglot - Riviera Dev 2015
Proud to be Polyglot - Riviera Dev 2015
 
Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications
 
MongoDB and Hadoop
MongoDB and HadoopMongoDB and Hadoop
MongoDB and Hadoop
 
Proud to be polyglot
Proud to be polyglotProud to be polyglot
Proud to be polyglot
 
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6
Devoxx 2014 : Atelier MongoDB - Decouverte de MongoDB 2.6
 
Some cool features of MongoDB
Some cool features of MongoDBSome cool features of MongoDB
Some cool features of MongoDB
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB Application
 
Opensourceday 2014-iot
Opensourceday 2014-iotOpensourceday 2014-iot
Opensourceday 2014-iot
 
Neotys conference
Neotys conferenceNeotys conference
Neotys conference
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with Couchbase
 
Introduction to NoSQL with Couchbase
Introduction to NoSQL with CouchbaseIntroduction to NoSQL with Couchbase
Introduction to NoSQL with Couchbase
 
Why and How to integrate Hadoop and NoSQL?
Why and How to integrate Hadoop and NoSQL?Why and How to integrate Hadoop and NoSQL?
Why and How to integrate Hadoop and NoSQL?
 
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
NoSQL Matters 2013 - Introduction to Map Reduce with Couchbase 2.0
 
Big Data Paris : Hadoop and NoSQL
Big Data Paris : Hadoop and NoSQLBig Data Paris : Hadoop and NoSQL
Big Data Paris : Hadoop and NoSQL
 
Big Data Israel Meetup : Couchbase and Big Data
Big Data Israel Meetup : Couchbase and Big DataBig Data Israel Meetup : Couchbase and Big Data
Big Data Israel Meetup : Couchbase and Big Data
 

Recently uploaded

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 

Recently uploaded (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 

Drop your table ! MongoDB Schema Design

  • 1. @SoftShakeEvent DROP TABLE ! Overview of Document Design Tugdual Grall Technical Evangelist MongoDB @tgrall Soft Shake ‘14
  • 2. {“about” : “me”} Tugdual “Tug” Grall • MongoDB Join me at the Gōng-fu I/O • Technical Evangelist • Couchbase • Technical Evangelist • eXo • CTO • Oracle • Developer/Product Manager • Mainly Java/SOA • Developer in consulting firms • Web • @tgrall • http://blog.grallandco.com • tgrall • NantesJUG co-founder • Pet Project : • http://www.resultri.com • tug@mongodb.com • tugdual@gmail.com
  • 3. With “Relations” Between Rows Customer ID First Name Last Name City 0 John Doe New York 1 Mark Smith San Francisco 2 Jay Black Newark 3 Meagan White London 4 Edward Daniels Boston Account Number Branch ID Account Type Customer ID 10 100 Checking 0 11 101 Savings 0 12 101 IRA 0 13 200 Checking 1 14 200 Savings 1 15 201 IRA 2
  • 4. But, some things are hard to model • Let’s look at a product catalog:
  • 5. Baseball Bat ! -3 length to weight ratio 2-5/8" barrel diameter Two-piece construction R2 alloy barrel provides outstanding durability, performance and "pop" R2 composite handle shifts weight into the bat's knob for ultra-fast swing speeds Rifle Barrel design removes weight from the barrel for thinner wall thickness Acoustic barrel offers that sweet-sounding "ping" Contact grip helps eliminate sting and vibration AIR Elite is RIP-IT's® fastest BBCOR bat and the one with the most performance BBCOR certified - approved for high school and collegiate play Includes RIP-IT's® "Love It Or Return It" 30 Day Refund Policy with free return shipping Manufacturer's warranty: 400 days Made in the USA Model: B1403E
  • 6. Bat Product Table Category Model Name Brand Length to weight ratio Barrel Dia Type Barrel Handle Cert. Country Price Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy R2 composite BBCOR USA $399.99 Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 Bat MCB1B One Marucci -3 2 5/8 One-piece AZ3000 aluminum AZ3000 aluminum BBCOR Imported $199.99 Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX SIC Black Carbon BBCOR China $399.99
  • 7. Lets Add Gloves Size: 12" Infield/Outfield/Pitcher model 2-Piece Web pattern Most popular MLB® pattern among pitchers Pro Stock® American steerhide leather offers rugged durability and a superior feel Dual-Welting™ on "exposed edges" of the fingers helps maintain pocket shape and durability Pro Stock™ hand-designed pattern for unbeatable craftsmanship Dri-Lex® ultra-breathable wrist lining repels moisture from your hand Black leather with rich brown embellishments Pattern: B212 Model: WTA2000BBB212 Wilson
  • 8. Bat and Glove Product Table Category Model Name Brand Length to weight ratio Barrel Dia Type Barrel Handle Cert. Country Price Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy R2 composite BBCOR USA $399.99 Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 Bat MCB1B One Marucci -3 2 5/8 One-piece AL AL BBCOR Imported $199.99 Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX SIC Black Carbon BBCOR China $399.99 Category Model Name Brand Size Position Pattern Web Pattern Material Color Country Price Glove WTA2000B BB212 A2000 Wilson 12" Infield B212 2-piece Leather black Vietnam $299.99 Glove PRO112PT HOH Pro Rawlings 11.25" Outfield Pro taper Modified Trap-Eze Horween Leather black China $229.99
  • 9. Add some baseballs Cover: Full grain leather for excellent durability Core: Cushioned cork core Additions/Technologies: Made to the exact specifications of MLB Stitching/Seams: 108 classic red stitches/Rawlings® Major League seaming League/Certification(s): MLB Balls included per purchase: individual Recommended Age: All ages Model : ROMLB Rawlings
  • 10. Bat and Glove and Ball Product Table Category Model Name Brand Length to weight ratio Barrel Dia Type Barrel Handle Cert. Country Price Bat B1403E Air Elite RIP-IT -3 2 5/8 Composite R2 Alloy R2 composite BBCOR USA $399.99 Bat B1403 Prototype RIP-IT -3 2 5/8 One-piece R1 Alloy R1 Alloy BBCOR USA $199.99 Bat MCB1B One Marucci -3 2 5/8 One-piece AL AL BBCOR Imported $199.99 Bat BB14S1 S1 Easton -3 2 5/8 Composite IMX SIC Black Carbon BBCOR China $399.99 Categor y Model Name Brand Size Position Pattern Web Pattern Material Color Country Price Glove WTA200 0BBB21 2 A2000 Wilson 12" Infield B212 2-piece Leather black Vietnam $299.99 Glove PRO112 PT HOH Pro Rawling s 11.25" Outfield Pro taper Modifie d Trap- Eze Horwee n Leather black China $229.99 Category Model Name Brand Color Cover Core Cert. Country Price Baseball DICRLLB1 PBG Little League Rawlings white Leather Cork rubber Little League China $4.99 Baseball ROML MLB Rawlings white Leather cork China $6.99
  • 11. Sparse Table Category Model Name Brand Length to weight ratio Barrel Dia Type Barrel Handle Certificati on Country Price Size Position Pattern Web Pattern Material Color Cover Core Bat B1403E Air Elite RIP-­‐IT -­‐3 2 5/8 Composite R2 Alloy R2 composite BBCOR USA $399.99 Bat B1403 Prototype RIP-­‐IT -­‐3 2 5/8 One-­‐piece R1 Alloy R1 Alloy BBCOR USA $199.99 Bat MCB1B One Marucci -­‐3 2 5/8 One-­‐piece AZ3000 aluminum AZ3000 aluminum BBCOR Imported $199.99 Bat BB14S1 S1 Easton -­‐3 2 5/8 Composite IMX SIC Black Carbon BBCOR China $399.99 Glove WTA2000BB B212 A2000 Wilson Vietnam $299.99 12" Infield B212 2-­‐piece Leather black Glove PRO112PT HOH Pro Rawlings China $229.99 11.25" Outfield Pro taper Modified Trap-­‐Eze Horween Leather black Baseball DICRLLB1PB G Little League Rawlings Little League China $4.99 white Leather cork and rubber Baseball ROML MLB Rawlings China $6.99 white Leather cork Continue adding columns as you add new products
  • 12. Maybe this design will work better prodID property value 1 length/ weight -3 1 barrel dia 2 5/8 1 type composite 1 certification BBCOR … 5 size 12 5 position infield 5 pattern B212 5 material leather 5 color black … 8 color white 8 cover leather 8 core cork prodID Category Model Name Brand Country Price 1 Bat B1403E Air Elite RIP-IT USA $399.99 2 Bat B1403 Prototype RIP-IT USA $199.99 3 Bat MCB1B One Marucci Imported $199.99 4 Bat BB14S1 S1 Easton China $399.99 5 Glove WTA2000B BB212 A2000 Wilson Vietnam $299.99 6 Glove PRO112PT HOH Pro Rawlings China $229.99 DICRLLB1 7 Baseball PBG Little League Rawlings China $4.99 8 Baseball ROML MLB Rawlings China $6.99
  • 13. It is hard to iterate New Column Name Age Phone Email New Table New Table New Column
  • 14. Have to Manage Changes in 3 Places Code XML Config DB Schema Relational Database Object Relational Application Mapping
  • 16. Match the Data in your Application Relational MongoDB { first_name: ‘Paul’, surname: ‘Miller’ city: ‘London’, location: [45.123,47.232], cars: [ { model: ‘Bentley’, year: 1973, value: 100000}, { model: ‘Rolls Royce’, year: 1965,! value: 330000}! } }
  • 17. Let’s go back to our product catalog
  • 18. How would we model this in MongoDB? Size: 12" Infield/Outfield/Pitcher model 2-Piece Web pattern Most popular MLB® pattern among pitchers Pro Stock® American steerhide leather offers rugged durability and a superior feel Dual-Welting™ on "exposed edges" of the fingers helps maintain pocket shape and durability Pro Stock™ hand-designed pattern for unbeatable craftsmanship Dri-Lex® ultra-breathable wrist lining repels moisture from your hand Black leather with rich brown embellishments Pattern: B212 Model: WTA2000BBB212 Wilson
  • 19. We use a document ! { category: “glove”, model: “PRO112PT”, name: “Air Elite”, brand: “Rawlings”, price: 229.99, available: Date(“2013-03-31”) } Fields Values Field values are typed string number date
  • 20. Documents are rich structures ! { category: “glove”, model: “PRO112PT”, name: “Air Elite”, brand: “Rawlings”, price: 229.99, available: Date(“2013-03-31”), position: [“infield”, “outfield”, “pitcher”] } Fields can contain arrays
  • 21. Documents are rich structures ! { category: “glove”, model: “PRO112PT”, name: “Air Elite”, brand: “Rawlings”, price: 229.99, available: Date(“2013-03-31”), position: [“infield”, “outfield”, “pitcher”], endorsed: {name: “Ryan Howard”, team: “Phillies”, position: “first base”}, } Fields can contain sub-documents
  • 22. ` { category: “glove”, model: “PRO112PT”, name: “Air Elite”, brand: “Rawlings”, price: 229.99, available: Date(“2013-03-31”), position: [“infield”, “outfield”, “pitcher”], endorsed: {name: “Ryan Howard”, team: “Phillies”, position: “first base”}, history: [{date: Date(“2013-03-31”), price: 279.99}, {date: Date(“2013-06-01”), price: 259.79}, {date: Date(“2013-08-15”), price: 229.99}] } Fields can contain an array of sub-documents
  • 23. Variation is easy with document model { category: bat, model: B1403E, name: Air Elite, brand: “Rip-IT”, price: 399.99 ! diameter: “2 5/8”, barrel: R2 Alloy, handle: R2 Composite, type: composite, } ! { category: glove, model: PRO112PT, name: Air Elite, brand: “Rawlings”, price: “229.99” ! size: 11.25, position: outfield, pattern: “Pro taper”, material: leather, color: black } { category: ball, model: ROML, name: MLB, brand: “Rawlings”, price: “6.99” ! cover: leather, core: cork, color: white }
  • 24. Relational Schema Design Focus on data storage
  • 25. Document Schema Design Focus on data use
  • 27. Schema Design Considerations • How do we manipulate the data? – Dynamic Ad-Hoc Queries – Atomic Updates – Aggregation • What are the access patterns of the application? – Read/Write Ratio – Types of Queries / Updates – Data life-cycle and growth rate
  • 28. Let's model something together How about a business card?
  • 30. Referencing Addresses! ! {! ! “_id”: 1,! ! “street”: “10260 Bandley Dr”,! ! “city”: “Cupertino”,! ! “state”: “CA”,! ! “zip_code”: ”95014”,! ! “country”: “USA”! } Contacts! ! {! “_id”: 2,! “name”: “Steven Jobs”,! “title”: “VP, New Product Development”,“company”: “Apple Computer”,! “phone”: “408-996-1010”,! “address_id”: 1! }
  • 31. Embedding Contacts! ! {! “_id”: 2,! “name”: “Steven Jobs”,! “title”: “VP, New Product Development”,! “company”: “Apple Computer”,! “address”: {! ! “street”: “10260 Bandley Dr”,! ! “city”: “Cupertino”,! ! “state”: “CA”,! ! “zip_code”: ”95014”,! ! “country”: “USA”! },! “phone”: “408-996-1010”! }!
  • 32. ! Contact Relational Schema ! • name • company • title • phone Address ! • street • city • state • zip_code
  • 33. ! Contact ! • name • company • adress address • Street street • City city • State • Zip zip_code • title • phone Document Schema
  • 34. Schema Flexibility {! “name”: “Steven Jobs”,! “title”: “VP, New Product Development”,! “company”: “Apple Computer”,! “address”: {! ! “street”: “10260 Bandley Dr”,! ! “city”: “Cupertino”,! ! “state”: “CA”,! ! “zip_code”: ”95014”! },! “phone”: “408-996-1010”! }! {! “name”: “Larry Page”,! “url”: “http://google.com/”,! “title”: “CEO”,! “company”: “Google!”,! “email”: “larry@google.com”,! “address”: {! “street”: “555 Bryant, #106”,! “city”: “Palo Alto”,! “state”: “CA”,! “zip_code”: “94301”! }! “phone”: “650-618-1499”,! “fax”: “650-330-0100”! }
  • 36. Let’s Look at an Address Book
  • 37. Groups N N ! • name Contacts • name • company • title Addresses • type • street • city • state • zip_code Phones • type • number Emails • type • address Twitters • name • location • web • bio Thumbnails • mime_type • data Portraits • mime_type • data N 1 1 1 1 1 1 1 1 N N 1 Address Book Entity-Relationship
  • 39. ! Contacts • name • company • title One to One Addresses • type • street • city • state • zip_code Phones • type • number Emails • type • address Thumbnails • mime_type • data Portraits • mime_type • data Groups • name N 1 N 1 N N N 1 1 1 1 1 Twitters • name • location • web • bio 1 1
  • 40. One to One General Recommendation • Full contact info all at once – Contact embeds twitter • Parent-child relationship – “contains” • twitter twitter 1 • No additional data duplication • Can query or index on embedded field – e.g., “twitter.name” – Exceptional cases… Contact • Reference portrait which has very large data
  • 41. ! Contacts • name • company • title One to Many Addresses • type • street • city • state • zip_code Phones • type • number Emails • type • address Thumbnails • mime_type • data Portraits • mime_type • data Groups • name N 1 N 1 N N N 1 1 1 1 1 Twitters • name • location • web • bio 1 1
  • 42. One to Many General Recommendation • Full contact info all at once – Contact embeds multiple phones • Parent-children relationship – “contains” • No additional data duplication • Can query or index on any field – e.g., { “phones.type”: “mobile” } – Exceptional cases… Contact • phones phone N • Scaling: maximum document size is 16MB
  • 43. ! Contacts • name • company • title Many to Many Addresses • type • street • city • state • zip_code Phones • type • number Emails • type • address Thumbnails • mime_type • data Portraits • mime_type • data Groups • name N 1 N 1 N N N 1 1 1 1 1 Twitters • name • location • web • bio 1 1
  • 44. Many to Many Traditional Relational Association X Join table ! Contacts • name • company • title • phone Groups • name GroupContacts • group_id • contact_id Use arrays instead
  • 45. Many to Many General Recommendation • Depends on use case 1. Simple address book • Contact references groups 2. Corporate email groups group contact N N • group_ids: [ ] • Group embeds contacts for performance • Exceptional cases – Scaling: maximum document size is 16MB – Scaling may affect performance and working set
  • 46. Contacts • name • company • title addresses • type • street • city • state • zip_code phones • type • number emails • type • address thumbnail • mime_type • data Groups • name N Portraits • mime_type • data N 1 1 twitter • name • location • web • bio N N N 1 1 Document model - holistic and efficient representation
  • 47. Contact document example {! ! “name” : “Gary J. Murakami, Ph.D.”,! ! “company” : “MongoDB, Inc.”,! ! “title” : “Lead Engineer”,! ! “twitter” : {! ! ! “name” : “Gary Murakami”, “location” : “New Providence, NJ”,! ! ! “web” : “http://www.nobell.org”! ! },! ! “portrait_id” : 1,! ! “addresses” : [ ! ! ! { “type” : “work”, “street” : ”229 W 43rd St.”, “city” : “New York”, “zip_code” : “10036” }! ! ],! ! “phones” : [ ! ! ! { “type” : “work”, “number” : “1-866-237-8815 x8015” }! ! ],! ! “emails” : [ ! ! ! { “type” : “work”, “address” : “gary.murakami@mongodb.com” },! ! ! { “type” : “home”, “address” : “gjm@nobell.org” }! ! ]! ! }!
  • 49. Legacy Migration 1. Copy existing schema & some data to MongoDB 2. Iterate schema design development Measure performance, find bottlenecks, and embed 1. one to one associations first 2. one to many associations next 3. many to many associations 3. Migrate full dataset to new schema New Software Application? Embed by default
  • 50. Embedding over Referencing • Embedding is a bit like pre-joined data – BSON (Binary JSON) document ops are easy for the server • Embed (90/10 following rule of thumb) – When the “one” or “many” objects are viewed in the context of their parent – For performance – For atomicity • Reference – When you need more scaling – For easy consistency with “many to many” associations without duplicated data
  • 51. It’s All About Your Application • Programs+Databases = (Big) Data Applications • Your schema is the impedance matcher – Design choices: normalize/denormalize, reference/embed – Melds programming with MongoDB for best of both – Flexible for development and change • Programs×MongoDB = Great Big Data Applications
  • 52. @SoftShakeEvent Thank You! Tugdual Grall Technical Evangelist MongoDB @tgrall Soft Shake ‘14