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

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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...Martijn de Jong
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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, Adobeapidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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...apidays
 
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 educationjfdjdjcjdnsjd
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

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