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

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

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