© joe mertz -m2c: building distributed applications 1 · 2017. 12. 4. · •due by wednesday (or...
TRANSCRIPT
![Page 1: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/1.jpg)
©JoeMertz- M2C:BuildingDistributedApplications 1
![Page 2: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/2.jpg)
• AnexampleofaNoSQL database• Isschema-less– Donotdefinetablesandcolumnsinadvance– Store newdatahoweverisneeded
• Stored asBSON• SimilartoJSON,butwitha fewmoredatatypes
– JSONisessentiallyserializedJavaScriptobjects» I.e. whatJavaScriptobjectswouldlooklikeifrepresentedasanobjectliteral
• ThereforeMongoDB essentiallystoresJavaScriptobjects– Easy tosaveaJavaScriptobject– Easy torestoreasaJavaScriptobject
©JoeMertz- M2C:BuildingDistributedApplications 2
![Page 3: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/3.jpg)
• Browse comparisonon:– http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart
©JoeMertz- M2C:BuildingDistributedApplications 3
![Page 4: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/4.jpg)
• ItisunclearwhetheritisbeneficialornottobethinkingintermsofRDBMSandmappingittoMongo.
• Myintuition:– ForgetaboutRDBMSinthiscase– JustseeMongo asasimplewaytostore,query,andretrieveJavaScriptobjects
©JoeMertz- M2C:BuildingDistributedApplications 4
![Page 5: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/5.jpg)
• Database– Adatabaseisasetofcollections
• Collections– Acollectionisasetofdocuments
• Documents– Adocumentis(essentially)aJSONstring
©JoeMertz- M2C:BuildingDistributedApplications 5
![Page 6: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/6.jpg)
• SaveandfindJSONdocuments– EachJSONdocument isnotrestricted tohavethesamestructure,buttheymostlydo
– Eachdocumenthas(globally) unique_id• ACollection isasetofJSONdocuments• ADatabaseis asetofJSONcollections
©JoeMertz- M2C:BuildingDistributedApplications 6
![Page 7: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/7.jpg)
• What ispassedtomongodb:{"name":"apple","price":1.99}
• Mongodb addsinan_id:{"name":"apple","price":1.99,"_id":ObjectId("35414c4ebb264d7000000000")}
©JoeMertz- M2C:BuildingDistributedApplications 7
![Page 8: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/8.jpg)
• Mongod – theMongoDB databaseserver– Listensbydefaultonport27017– Requests/responsesviaaMongoDB protocol
• Mongo– aMongoDB shellapplication– AJavaScript shelltointeractwithMongoDB– Candoalldatabaseoperations
• MongoDB drivers– Existformany languages– Providesalanguage-specificAPIforinteractingwithMongoDB
©JoeMertz- M2C:BuildingDistributedApplications 8
![Page 9: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/9.jpg)
• Scan:– https://www.mongodb.com/who-uses-mongodb
©JoeMertz- M2C:BuildingDistributedApplications 9
![Page 10: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/10.jpg)
• SQL and NoSQLDBMSseachhavetheirstrengths• Ourpurposein67-328:– Exposure:havebasicknowledgeofit– AneasywaytostoreandretrievedatainaformveryclosetoJavaScriptobjects(BSON)
©JoeMertz- M2C:BuildingDistributedApplications 10
![Page 11: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/11.jpg)
• Browseto:https://docs.mongodb.com/manual/administration/install-community/
• Followthedownloadinstructions:–MacOS:IfoundinstallingHomeBrew andthenMongoDB tobeeasy.
• Experimentwithmongoshell:– Start:https://docs.mongodb.org/getting-started/shell/import-data/
– FollowtheirexamplethroughRemoveData
©JoeMertz- M2C:BuildingDistributedApplications 11
![Page 12: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/12.jpg)
• Studio3Thasafreeversiontoview/editmongoDB databases
©JoeMertz- M2C:BuildingDistributedApplications 12
![Page 13: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/13.jpg)
• Inthemongoshell,youcandirectlyinteractwiththemongod inaREPL.
• Tointeractwithmongod fromwithinanodeprogram,usethenpm modulemongodb:– npm installmongodb -- save
©JoeMertz- M2C:BuildingDistributedApplications 13
![Page 14: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/14.jpg)
• Runmongodb• Runmongo• Runmongodb example
• YoucanfindtheAPIforthedemonstratedcollectionmethodsat:– http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html
©JoeMertz- M2C:BuildingDistributedApplications 14
![Page 15: © Joe Mertz -M2C: Building Distributed Applications 1 · 2017. 12. 4. · •Due by Wednesday (or first 10 min in class): –mLabIntroduction •Due November 20 –Implement simple](https://reader035.vdocuments.us/reader035/viewer/2022081621/611e5526d22a7e64e8743e00/html5/thumbnails/15.jpg)
• DuebyWednesday(orfirst10mininclass):– mLab Introduction
• DueNovember20– ImplementsimpleCRUDoperationsforwhatyouarepersistinginyourfinalproject.
– Haveatleastasinglewebpagefromwhichyoucanget,post,(put,)anddeletedocumentstoaMongoDBdatabase.
– Youdon'thavetodoallyourfinalprojectcollections,butyouneedtodoonecollectionofdocuments,andatleast3attributesperdocument.
©JoeMertz- M2C:BuildingDistributedApplications 15