SlideShare a Scribd company logo
1 of 31
Download to read offline
Startup tech arsenal!
João Vazão Vasques
ABOUT ME
@JoaoVasques
@JoaoVasques
joao.l.v.vasques
jv@uniplaces.com
AGENDA
PART I - MongoDB
MongoDB topics
● Basic concepts
● Operations
● Data modeling
● Performance and tools
Basic concepts 1-2
● NoSQL
● No transactions
○ Eventual consistency
● No schema
○ Flexibility: code defines your schema
● Scaling (Horizontal scaling)
● Document oriented
○ BJSON
Basic concepts 2-2
Database
Table
Indexes
Columns
Row
Database
Collections
Indexes
Fields
Documents
Relational MongoDB
So we have...
Databases containing collections. A
collection is made up of documents.
Each document is made up of fields
Operations
● Document example (Uniplaces listing)
{
"title": "Uniplaces Mega mansion",
"rentable": false,
"location" : {
"city" : "Lisboa",
"coordinates" : {
"longitude" : -9.145782599999961,
"latitude" : 38.7234037
}
},
"apartment_details" : {
"bathrooms" : 2,
"bedrooms" : 6,
},
}
Operations
Insert listings - insert
db.listings.insert( { title: "Erasmus Residence", rentable: true } )
db.listings.insert( {title: "xpto", rentable: true, location: [{city:
"lisbon", coordinates: {latitude: 0, longitude: 90} } ] } )
Operations
Update listings - update
Syntax: update( < query>, <update>, <options>)
Problem!
We want to make "Mansion" rentable.
Solution (easy)!
db.listings.update( { title: "Uniplaces Mega Mansion"}, {rentable: true } )
Search for Mega Mansion and...
Operations
Update listings 2 -2
Reason: second parameter replaces the original. We replaced the entire
document with a new one. Ups!
Solution - $set
Used when you want to change a value of one, or a few, fields
db.listings.update( { title: "Uniplaces Mega Mansion"}, { $set: {rentable: true } } )
Other update modifiers: $inc, $unset, $push, $pop
Search listings - find (1 - 2)
Syntax: find( < query>, <projection>)
Projection
db.listings.find( { title: "Uniplaces Mega mansion"}, {rentable: 1} )
Logical operators ($and)
db.listings.find({ $and: [{ title: "Uniplaces Mega Mansion"}, {rentable: "false"}] })
Comparison operators ($gte)
db.listings.find( { "apartment_details.bedrooms" : {$gte: 2 } }, { title: 1} )
Operations
Search listings - find (2 - 2)
Ordering (sort: -1 descending, 1 ascending)
db.listings.find({ $gte: { "apartment_details.bedrooms" : 2 }).sort
("apartment_details.bedrooms": -1)
Paging (limit and skip)
db.listings.find().limit(3).skip(1)
Operations
● MongoDB does not support Joins
● Embedded Documents
{
"title": "Uniplaces Mega mansion",
"bedrooms" : [
{
"price" : 500,
"area": 25
},
{
"price" : 700,
"area": 30
},
]
}
db.listings.find( {bedrooms: { $elemMatch: {price: { $gt: 20 }, area: 25} } })
Data modeling
Considerations:
● Geography
● System errors
○ ensure your backups can "survive"
● Production constraints
○ Schedule according to system usage
● Database configuration
○ Replication & Sharding
Backups 1 -3
Approaches to backup MongoDB systems
● Binary database dumps
○ Small
○ Don't include index content and padding
○ Cannot reflect single moment in time
● Filesystem snapshots
○ Large backup sizes
○ Accurate
○ Require filesystem and OS tools
○ Can reflect a single moment in time
■ Note: in sharding all writes must be suspended
Backups 2-3
Backup and restore example
● Backup database
> mongodump -v -d test -o dump
● Restore database
> mongorestore -v --db test dump
Backups 3-3
● Writes to primary (only)
○ A write is fully committed once it has replicated to a majority of servers
in the set
● Reads to primary and secondary
● Consensus election in case of primary fail
Replica Sets
Secondary
Secondary
Primary
W
W
W
Secondary
W
END OF PART I
Part II - Coding Time!
Part II - Coding Time!
Weapons we'll be using
● Web framework written in Scala & Java
● MVC paradigm
● Built on Akka
● Built in testing tools
● IDE support (Eclipse and IntelliJ IDEA)
About Play!
MVC
Model - View - Controller
Anatomy of a Play! application
Coding samples
routing
Coding samples
template engine
Download the demo project on Github
● https://github.com/JoaoVasques/mongodb-workshop
Challenges:
● Fire Employee
● Search employee
● Create a backup of the database and restore it
Hands on time!!!
● engineering.linkedin.com
● blog.twitter.com/engineering
● facebook.com/Engineering
● engineering.foursquare.com
● nerds.airbnb.com
Cool tech blogs
Thank you!

More Related Content

What's hot

How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...Oleksandr Tarasenko
 
[WebMuses] Big data dla zdezorientowanych
[WebMuses] Big data dla zdezorientowanych[WebMuses] Big data dla zdezorientowanych
[WebMuses] Big data dla zdezorientowanychPrzemek Maciolek
 
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map EngineAGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map EngineCamptocamp
 
Omnibus database machine
Omnibus database machineOmnibus database machine
Omnibus database machineAleck Landgraf
 
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017Alexey Grigorev
 
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBMarch 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBJosiah Carlson
 
Geolocalização com MongoDB e Rails
Geolocalização com MongoDB e RailsGeolocalização com MongoDB e Rails
Geolocalização com MongoDB e RailsMaurício Maia
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introductionsethfloydjr
 

What's hot (12)

How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...
 
[WebMuses] Big data dla zdezorientowanych
[WebMuses] Big data dla zdezorientowanych[WebMuses] Big data dla zdezorientowanych
[WebMuses] Big data dla zdezorientowanych
 
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map EngineAGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
 
Browses
BrowsesBrowses
Browses
 
Omnibus database machine
Omnibus database machineOmnibus database machine
Omnibus database machine
 
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
 
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBMarch 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
 
Logging in JavaScript - Part-3
Logging in JavaScript - Part-3Logging in JavaScript - Part-3
Logging in JavaScript - Part-3
 
Geolocalização com MongoDB e Rails
Geolocalização com MongoDB e RailsGeolocalização com MongoDB e Rails
Geolocalização com MongoDB e Rails
 
Bitcoin:Next
Bitcoin:NextBitcoin:Next
Bitcoin:Next
 
Querying mongo db
Querying mongo dbQuerying mongo db
Querying mongo db
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 

Similar to MongoDB and Play! Framework workshop

Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patternsjoergreichert
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDBElieHannouch
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseRuben Inoto Soto
 
MongoDB and the Internet of Things
MongoDB and the Internet of ThingsMongoDB and the Internet of Things
MongoDB and the Internet of ThingsSam_Francis
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)MongoDB
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBMongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...festival ICT 2016
 
Storage dei dati con MongoDB
Storage dei dati con MongoDBStorage dei dati con MongoDB
Storage dei dati con MongoDBAndrea Balducci
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongoMichael Bright
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and PythonMike Bright
 
NoSQL Solutions - a comparative study
NoSQL Solutions - a comparative studyNoSQL Solutions - a comparative study
NoSQL Solutions - a comparative studyGuillaume Lefranc
 
MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB
 
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...MongoDB
 
Postgres-XC as a Key Value Store Compared To MongoDB
Postgres-XC as a Key Value Store Compared To MongoDBPostgres-XC as a Key Value Store Compared To MongoDB
Postgres-XC as a Key Value Store Compared To MongoDBMason Sharp
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentationMurat Çakal
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Ido Green
 

Similar to MongoDB and Play! Framework workshop (20)

Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL Database
 
MongoDB and the Internet of Things
MongoDB and the Internet of ThingsMongoDB and the Internet of Things
MongoDB and the Internet of Things
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
MongoDB Basics Unileon
MongoDB Basics UnileonMongoDB Basics Unileon
MongoDB Basics Unileon
 
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...
Lab pratico per la progettazione di soluzioni MongoDB in ambito Internet of T...
 
Storage dei dati con MongoDB
Storage dei dati con MongoDBStorage dei dati con MongoDB
Storage dei dati con MongoDB
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 
NoSQL Solutions - a comparative study
NoSQL Solutions - a comparative studyNoSQL Solutions - a comparative study
NoSQL Solutions - a comparative study
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data Presentation
 
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...
MongoDB IoT City Tour LONDON: Managing the Database Complexity, by Arthur Vie...
 
MongoDB.pdf
MongoDB.pdfMongoDB.pdf
MongoDB.pdf
 
Postgres-XC as a Key Value Store Compared To MongoDB
Postgres-XC as a Key Value Store Compared To MongoDBPostgres-XC as a Key Value Store Compared To MongoDB
Postgres-XC as a Key Value Store Compared To MongoDB
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

MongoDB and Play! Framework workshop

  • 4. PART I - MongoDB
  • 5. MongoDB topics ● Basic concepts ● Operations ● Data modeling ● Performance and tools
  • 6. Basic concepts 1-2 ● NoSQL ● No transactions ○ Eventual consistency ● No schema ○ Flexibility: code defines your schema ● Scaling (Horizontal scaling) ● Document oriented ○ BJSON
  • 8. So we have... Databases containing collections. A collection is made up of documents. Each document is made up of fields
  • 9. Operations ● Document example (Uniplaces listing) { "title": "Uniplaces Mega mansion", "rentable": false, "location" : { "city" : "Lisboa", "coordinates" : { "longitude" : -9.145782599999961, "latitude" : 38.7234037 } }, "apartment_details" : { "bathrooms" : 2, "bedrooms" : 6, }, }
  • 10. Operations Insert listings - insert db.listings.insert( { title: "Erasmus Residence", rentable: true } ) db.listings.insert( {title: "xpto", rentable: true, location: [{city: "lisbon", coordinates: {latitude: 0, longitude: 90} } ] } )
  • 11. Operations Update listings - update Syntax: update( < query>, <update>, <options>) Problem! We want to make "Mansion" rentable. Solution (easy)! db.listings.update( { title: "Uniplaces Mega Mansion"}, {rentable: true } ) Search for Mega Mansion and...
  • 12.
  • 13. Operations Update listings 2 -2 Reason: second parameter replaces the original. We replaced the entire document with a new one. Ups! Solution - $set Used when you want to change a value of one, or a few, fields db.listings.update( { title: "Uniplaces Mega Mansion"}, { $set: {rentable: true } } ) Other update modifiers: $inc, $unset, $push, $pop
  • 14. Search listings - find (1 - 2) Syntax: find( < query>, <projection>) Projection db.listings.find( { title: "Uniplaces Mega mansion"}, {rentable: 1} ) Logical operators ($and) db.listings.find({ $and: [{ title: "Uniplaces Mega Mansion"}, {rentable: "false"}] }) Comparison operators ($gte) db.listings.find( { "apartment_details.bedrooms" : {$gte: 2 } }, { title: 1} ) Operations
  • 15. Search listings - find (2 - 2) Ordering (sort: -1 descending, 1 ascending) db.listings.find({ $gte: { "apartment_details.bedrooms" : 2 }).sort ("apartment_details.bedrooms": -1) Paging (limit and skip) db.listings.find().limit(3).skip(1) Operations
  • 16. ● MongoDB does not support Joins ● Embedded Documents { "title": "Uniplaces Mega mansion", "bedrooms" : [ { "price" : 500, "area": 25 }, { "price" : 700, "area": 30 }, ] } db.listings.find( {bedrooms: { $elemMatch: {price: { $gt: 20 }, area: 25} } }) Data modeling
  • 17. Considerations: ● Geography ● System errors ○ ensure your backups can "survive" ● Production constraints ○ Schedule according to system usage ● Database configuration ○ Replication & Sharding Backups 1 -3
  • 18. Approaches to backup MongoDB systems ● Binary database dumps ○ Small ○ Don't include index content and padding ○ Cannot reflect single moment in time ● Filesystem snapshots ○ Large backup sizes ○ Accurate ○ Require filesystem and OS tools ○ Can reflect a single moment in time ■ Note: in sharding all writes must be suspended Backups 2-3
  • 19. Backup and restore example ● Backup database > mongodump -v -d test -o dump ● Restore database > mongorestore -v --db test dump Backups 3-3
  • 20. ● Writes to primary (only) ○ A write is fully committed once it has replicated to a majority of servers in the set ● Reads to primary and secondary ● Consensus election in case of primary fail Replica Sets Secondary Secondary Primary W W W Secondary W
  • 22. Part II - Coding Time!
  • 23. Part II - Coding Time! Weapons we'll be using
  • 24. ● Web framework written in Scala & Java ● MVC paradigm ● Built on Akka ● Built in testing tools ● IDE support (Eclipse and IntelliJ IDEA) About Play!
  • 25. MVC Model - View - Controller
  • 26. Anatomy of a Play! application
  • 29. Download the demo project on Github ● https://github.com/JoaoVasques/mongodb-workshop Challenges: ● Fire Employee ● Search employee ● Create a backup of the database and restore it Hands on time!!!
  • 30. ● engineering.linkedin.com ● blog.twitter.com/engineering ● facebook.com/Engineering ● engineering.foursquare.com ● nerds.airbnb.com Cool tech blogs