goodbye rows and tables, hello documents and collections
TRANSCRIPT
![Page 1: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/1.jpg)
Goodbye rows and tables, hello documents and collections
![Page 2: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/2.jpg)
Lots of pretty pictures to fool you.
![Page 3: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/3.jpg)
Noise
![Page 4: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/4.jpg)
Introduction
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality).
MongoDB is document-oriented, schema-free, scalable, high-performance, open source. Written in C++
Mongo is not a relational database like MySQL
Goodbye rows and tables, hello documents and collections
FeaturesDocument-oriented
Documents (objects) map nicely to programming language data types Embedded documents and arrays reduce need for joins No joins and no multi-document transactions for high performance and easy scalability
High performance No joins and embedding makes reads and writes fast Indexes including indexing of keys from embedded documents and arrays
High availability Replicated servers with automatic master failover
Easy scalability Automatic sharding (auto-partitioning of data across servers)
Reads and writes are distributed over shards No joins or multi-document transactions make distributed queries easy and fast
Eventually-consistent reads can be distributed over replicated servers
![Page 5: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/5.jpg)
Why ?
Cost - MongoDB is free MongoDb is easily installable. MongoDb supports various programming languages like C, C++,
Java,Javascript, PHP. MongoDB is blazingly fast MongoDB is schemaless Ease of scale-out
If load increases it can be distributed to other nodes across computer networks. It's trivially easy to add more fields -- even complex fields -- to your objects.
So as requirements change, you can adapt code quickly. Background Indexing MongoDB is a stand-alone server Development time is faster, too, since there are no schemas to manage. It supports Server-side JavaScript execution.
Which allows a developer to use a single programming language for both client and server side code
![Page 6: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/6.jpg)
Limitations
Mongo is limited to a total data size of 2GB for all databases in 32-bit mode.
No referential integrity
Data size in MongoDB is typically higher.
At the moment Map/Reduce (e.g. to do aggregations/data analysis) is OK,
but not blisteringly fast.
Group By : less than 10,000 keys.
For larger grouping operations without limits, please use map/reduce .
Lack of predefined schema is a double-edged sword
No support for Joins & transactions
![Page 7: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/7.jpg)
Benchmarking (MongoDB Vs. MySQL)
Script 1 (Insert) Script 2 (Insert) Script 3 (Select)
0
5000
10000
15000
20000
25000
MySQL
MongoDB
Test Machine configuration:
CPU : Intel Xeon 1.6 GHz - Quad Core, 64 BitMemory : 8 GB RAM
OS : Centos 5.2 - Kernel 2.6.18 64 bit
Record StructureField1 -> String, IndexedField2 -> String, IndexedFiled3 -> Date, Not IndexedFiled4 -> Integer, Indexed
![Page 8: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/8.jpg)
Mongo data model
MySQL Term Mongo Term
database database
table collection
index index
row BSON document
column BSON field
Primary key _id field
A Mongo system (see deployment above) holds a set of databasesA database holds a set of collectionsA collection holds a set of documentsA document is a set of fieldsA field is a key-value pairA key is a name (string)A value is a
basic type like string, integer, float, timestamp, binary, etc., a document, or an array of values
![Page 9: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/9.jpg)
SQL to Mongo Mapping Chart
![Page 10: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/10.jpg)
Continued ...
SQL Statement Mongo Statement
![Page 11: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/11.jpg)
Replication / Sharding
Data Redundancy Automated Failover Distribute read load Simplify maintenance (compared to "normal" master-slave) Disaster recovery from user error
Automatic balancing for changes in load and data distribution Easy addition of new machines Scaling out to one thousand nodes No single points of failure Automatic failover
![Page 12: Goodbye rows and tables, hello documents and collections](https://reader036.vdocument.in/reader036/viewer/2022062517/56649e8e5503460f94b91cc6/html5/thumbnails/12.jpg)
These slides are online:http://amardeep.in/intro_to_mongodb.ppt