MongoDB First Light. Mongo DB Basics Mongo is a document based NoSQL. –A document is just a JSON object. –A collection is just a (large) set of documents.

Slides:



Advertisements
Similar presentations
Introduction to MongoDB
Advertisements

Mongo An alternative database system. Installing Mongo We must install both the Mongo database and at least one GUI for managing Mongo See
My first computer: The Apple ][ It wanted to be programmed.
Overview on ZHT 1.  General terms  Overview to NoSQL dabases and key-value stores  Introduction to ZHT  CS554 projects 2.
Relational Database Alternatives NoSQL. Choosing A Data Model Relational database underpin legacy applications and meet business needs However, companies.
Graph databases …the other end of the NoSQL spectrum. Material taken from NoSQL Distilled and Seven Databases in Seven Weeks.
Building applications with MongoDB – An introduction Roger
A Social blog using MongoDB ITEC-810 Final Presentation Lucero Soria Supervisor: Dr. Jian Yang.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Data Modeling.
4/20/2017.
Massively Parallel Cloud Data Storage Systems S. Sudarshan IIT Bombay.
1 Yasin N. Silva Arizona State University This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
IST Databases and DBMSs Todd S. Bacastow January 2005.
Databases with Scalable capabilities Presented by Mike Trischetta.
MONGODB NOSQL SERIES Karol Rástočný 1. Prominent Users 2  AppScale, bit.ly, Business Insider, CERN LHC, craigslist, diaspora, Disney Interactive Media.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
HBase A column-centered database 1. Overview An Apache project Influenced by Google’s BigTable Built on Hadoop ▫A distributed file system ▫Supports Map-Reduce.
NoSQL continued CMSC 461 Michael Wilson. MongoDB  MongoDB is another NoSQL solution  Provides a bit more structure than a solution like Accumulo  Data.
Getting Biologists off ACID Ryan Verdon 3/13/12. Outline Thesis Idea Specific database Effects of losing ACID What is a NoSQL database Types of NoSQL.
WTT Workshop de Tendências Tecnológicas 2014
Goodbye rows and tables, hello documents and collections.
Modern Databases NoSQL and NewSQL Willem Visser RW334.
NOSQL DATABASES Please remember to read the NOSQL Distilled book and the Seven Databases book.
Methodological Foundations of Biomedical Informatics (BMSC-GA 4449) Himanshu Grover.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Exam and Lecture Overview.
WEEK 1, DAY 2 STEVE CHENOWETH CSSE DEPT CSSE 533 –INTRO TO MONGODB.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture.
MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built.
Introduction to MongoDB
MongoDB Jer-Shuan Lin.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Modeling MongoDB with Relational Model Proposed by Christopher Polanco.
Big Data and NoSQL What and Why?. Motivation: Size WWW has spawned a new era of applications that need to store and query very large data sets –Facebook.
NOSQL DATABASE Not Only SQL DATABASE
Replication Store it in multiple places.... Literature Colouris, Dollimore, Kindberg, 2000 –Gets deep into the details of reliable communication, byzantine.
Introduction to MongoDB. Database compared.
NoSQL databases A brief introduction NoSQL databases1.
Orion Contextbroker PROF. DR. SERGIO TAKEO KOFUJI PROF. MS. FÁBIO H. CABRINI PSI – 5120 – TÓPICOS EM COMPUTAÇÃO EM NUVEM
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
CSE-291 (Distributed Systems) Winter 2017 Gregory Kesden
Mongo Database (Intermediate)
NO SQL for SQL DBA Dilip Nayak & Dan Hess.
and Big Data Storage Systems
Cloud Computing and Architecuture
MongoDB Er. Shiva K. Shrestha ME Computer, NCIT
MongoDB Distributed Write and Read
Modern Databases NoSQL and NewSQL
Dineesha Suraweera.
javascript for your data
Twitter & NoSQL Integration with MVC4 Web API
NOSQL databases and Big Data Storage Systems
New Mexico State University
CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden
…and web frameworks in general
Massively Parallel Cloud Data Storage Systems
Arrested by the CAP Handling Data in Distributed Systems
MongoDB for the SQL DBA.
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
CS5220 Advanced Topics in Web Programming Introduction to MongoDB
Building applications with MongoDB – An introduction
Azure Cosmos DB with SQL API .Net SDK
…and web frameworks in general
Lecture 15: Databases II Wednesday Feburary 28, 2018
Comparison of table-based and JSON-based chaincode
CMPE 280 Web UI Design and Development March 14 Class Meeting
NoSQL & Document Stores
NoSQL databases An introduction and comparison between Mongodb and Mysql document store.
Server & Tools Business
Presentation transcript:

MongoDB First Light

Mongo DB Basics Mongo is a document based NoSQL. –A document is just a JSON object. –A collection is just a (large) set of documents –A database is just a set of collections. JSON = JavaScript Object Notation –Actually BSON = binary encoded JSON Mongo shell is a JavaScript interpreter! –(And I have never coded JavaScript, ahem...) B Christensen 2

An In-between NoSQL The ends of the spectrum –Key-value stores Know the key to access opaque blob of anything Fire-and-forget (write-and-forget) –RDB Elaborate ad-hoc queries over highly structured data (Schema) Normalized meaning ‘lots’ of tables Transactions MongoDB sits somewhere in the middle Documents have elaborate (OO) structure (but not fixed!) Rather powerful query language (no joins though) From fire-and-forget to ‘acknowledge write on all replica’ B Christensen3

JSON Get used to key/value pairs! { course: ”SAiP”, semester:”E12”, teacher: ”hbc” } Basically close to fields of OO languages –The architectural mismatch between programming language and DB concepts is lessened! B Christensen 4

Basic commands… MongoDB creates objects and collections in the fly… B Christensen 5

No schema enforced... B Christensen6

Schema: Pro and Con Schema can provide a lot of data safety –Validating data, avoid hard-to-find bugs in clients,... However, they are also costly to migrate MongoDB is pretty handy in agile and early development when the ‘schema’ changes often... B Christensen7

find() You can formulate simple queries using ‘find()’ on a collection. Of course, the parameter of find is –A JSON object! B Christensen 8

More complex queries Regular expressions, and, or... B Christensen9

Hey – what about updates? Update –1 argument: the document to find –2 argument: the values to add/set/update B Christensen10 Mongo 3 has updated the API a bit!

Adding more structure Now, after I go home you decide to give my talk grades. –No new tables, schema, etc. –We just add more structure, similar to OO Ahh – one late grade arrives – justs $push it B Christensen11

Or - using SkyCave Bærbak Christensen12

RoomRecord like stuff Bærbak Christensen13

Pretty() is pretty nice Bærbak Christensen14

RegExps Bærbak Christensen15

Sorting on fields Bærbak Christensen16

Bounded result: ‘limit’ Bærbak Christensen17

Wall exercise? Bærbak Christensen18

Adding msg Bærbak Christensen19

Players Bærbak Christensen20

Now… How do we compose the ‘getShortRoomDesc()’? SELECT r.desc FROM room r, player p WHERE p.name = ”Mikkel” AND p.pos = r. pos ??? Bærbak Christensen21

The NoSQL answer The NoSQL answer: Manual references! –It is client-side responsibility to join Find p.pos using query 1; next find r.desc using query 2 –(§4.4.2 in MongoDB manual 3.0.6) Exercise –Why it is this the right answer in a NoSQL world? Hint: Think clients, think CPU cycles – where? Bærbak Christensen22

Alternatives Solution 2: –Denormalize / Embedded documents But not always possible for complex data structures But may actually slow queries down depending on search patterns –Searching inside documents is more tedious Solution 3: –DBRefs special MongoDB feature to make it even more SQL like B Christensen23

MongoDB modeling Comparing Documents to Tables B Christensen24

Entry on social network site: Schema B Christensen25

As RDB Schema The RDB version B Christensen26

Discussion Thus Mongo has less need for joining because the datamodel is richer –Arrays of complex objects –Sub objects Avoids the RDB idioms for modeling OneToMany relations ManyToMany handled by manual references –Two ‘find()’ instead of one ‘Select’ And –Replaces many random reads with fewer sequential B Christensen27

Going Large Durability, Scaling, Replication and Sharding B Christensen28

Durability RDBs guaranty Durability –Once a data update is acknowledged, data is stored MongoDB is configurable (write concern) –Unacknowledge:fire-and-forget –Acknowledged:acknowledge the write operation –Journaled:at least one will store data –Replica acknow.:at least N replica has received the write operation B Christensen29

Scaling out To get more power/space – just add more... B Christensen30

Replication Replica sets –Primary (handles writes/reads) –N secondaries (only reads) –Eventual consistency! Failover is automatic –Secondary votes –New primary selected Experience: Easy! B Christensen31

Sharding Key goals –No change in the client side API! When our EcoSense data grows out of its boxes we do not have to change our client programs! –Auto sharding You configure your shard key as ranges on your document keys –Shard balancing Migrates data automatically if one shard grows too large Experience: Nope  B Christensen32