This document provides an overview of MongoDB including:
- What MongoDB is and why it is used as a NoSQL database with advantages like speed, scalability and support for agile development.
- Key differences between SQL and NoSQL databases, with MongoDB being a document-based NoSQL database.
- Explanations of schema-free data structures in MongoDB and use of JSON/BSON formats.
- A brief overview of how MongoDB works and installation/demo.
6. NoSQL
• Stands for Not Only SQL
• Do not require a fixed schema
• Relaxation for one or more ACID properties.
• #3V
• Volume, Velocity and Variety
NoSQL
Document
based
MongoDB,
Azure Cosmos
Key-Value
Store
Redis
Column based
Cassandra,
HBase
Graph Store
Neo4j,
Amazon
DynamoDB
7. Why ?
• Speed
• Ease of Use
• Scalability & Performance is better
• Support of Agile Development
• Aggregation framework
• Ad hoc queries
• Replication
8. What does schema-free mean?
• NoSQL databases are either schema-free or have relaxed schemas
• Do not require any sort of definition of the schema of the data
9. What does schema-free mean?
Id Fname Email
1 Jon Jon@test.com
2 Alison Alison@test.com
3 Hanna
18. Microsoft Azure Bangladesh
group: www.facebook.com/groups/microsoft.azure.bd
fan page: fb.com/microsoft.azure.bd
Asp.Net - Bangladesh
www.facebook.com/groups/asp.net.mvc.bd
Community Group
Hello everybody , that you for joining to the exciting course MongoDB.
This course brought to you by Inishgitn….
So, this video series actually devided into 5 modules!
This is happen to be the very first one.
In todays lecture we are going to talk about the fundamental things , what mongodb is? Where it fits? What are the different terminology is used in mongo world and so on.
After that, in module 2 we talk about Schema design & data modeling…
And from there we will jump to CRUD operation in moduel 3
In module 4, we talk about indexing and aggression, which is a very important topic.
Last but no least we talk about some mongo administrive work in module 5.
Before going for the deep dive, let me introduce myself.
I am your trainer SH. I am solution Architect , currently I am working for Insightin technology.
You will find me on all the popular social network.Feel free to contact me.
So, what is MongoDB?
Well, Mongodb is NoSQL documented based cross-platform database.
We will talk about what NoSQL is, what document based mean in the upcoming slide
But before that let me tell you one side note :
Interestingly, the company behind mongoDB is also called mongodb but with mongodb, I of course mean the database.
So, don’t get confuse with that part.
Before going to NoSQL , let me answer one of the popular question. What is the difference between SQL and NoSQL.
In order to make any sustainable successful project choosing the right database is very crusial. And for that, you have to understand how both the database works, what separate these two world.
Now, Lets start with SQL. SQL is not a DATABASE!
It stands for Structured Query language. In simple term, it is a language that allows you to write database query.
Query something like this:
This query is mainly for data retreiveal, but there is also query for insertion, update and delete.
Another important difference is that , In relational database data may exist in multiple database, if that does you can do join.
NoSQL usually don’t have the concept of JOIN.
In sumaary:
- SQL has Strict schema
And Relationship exists between table , so there can have many to many, one to one realtionship
Next, lets talk about NOSQL
It does not require a fixed scehma.
Since there is no fixed schema so, NO Concept of JOIN exist.
NoSQL is used for Big data and real-time web apps.
NoSQL is often refered as 3V.
Volume : indicate you will expect huge amount of dataVelocity : indicates that the data data production is very fast.Variety : means data can come in many form, they could be Structured, Semi-Structured, UnStructured or even Polymorphic.
Agile Friendly:
ACID is not strictly followed in NoSQL.
Atomicity: Atomicity means that the system ensures/guarantee that all of a transaction happens, or none of it does.
Consistency: Consistency means that your system ensures/guarantee that your data will be consistent after your first commit.
Isolation: Isolation means that one transaction cannot read data from another transaction that is not yet completed.
If two transactions are executing concurrently, each one will see the world as if they were executing sequentially, and if one needs to read data
that is written by another, it will have to wait until the other is finished.
For say, if Mr. X issues a transaction against a database at the same time that Mr. Y issues a different transaction,
both transactions should operate on the database in an isolated manner. The database should perform those transaction one after another.
Durability: Durability refers to the guarantee that once the user has been notified of success, the transaction will persist, and not be undone.
So, this is all about ACID.
NoSQL database can be many type. Some are document based, some are column based , some can be graph based. All of them have their own pros and cons. Feel free to check them online.
Now of course we already got database solutions, we've got mySQL, we've got postgres, we've got thousands of database solutions already,
so how is mongodb different and why it is so popular?
It is popular because of speed and Ease of Use.
Scaling is one of the tough problem that every databse face. To overcome this MongoDB has sharding feature.
MongoDB supports range query, regular expression and many more types of searches.
Replication is being provided by distributing data across different machines.
- MapReduce can be used for batch processing. Just in case if you don’t know what MapReduce is , its nothing but a process, in which large datasets will process.
So, what does schema-free mean?
Well, schema less means the database don't have fixed data structure
You can facilate the structure as per your requirement.
Mongodb provides the schema-free facility with JSON-style data store, you can change the data structure as per your requirement.
Lets see an example.
Lets define a table with a schema first….
In our case, the schema contains Id, Name and Email address.
Since we have a very fixed schema, things could become little challenging if we need to incorporate new information in the schema…
Lets say , we want to include special skills as well. Now, of course we could introduce a new column.
Now, not everybody have special skills , so adding a whole new column may not be a good idea always.
At this point you are left with another option and this is joining….
This could be problematic and expensive if we want to add new column for only few particular records.
Things become lot easier when no longer you have to worry about weather your data is going to fit in your schema.
And that’s where NoSQL shines.
Now, lets talk about JSON and BSON.
In the last slide, we said data can be stored in a document. But we did not say how those documents are structured.
We vaguely said we will store data in document. But what are the elements that make a mongo document?
Well, those document are in JSON format.
JSON stands for JavaScript object Notaiton. Its an an open, human and machine-readable standard , its mainly used for data interchange.
Behind the scene, MongoDB process the JSON documents in binary-encoded format called BSON.
BSON extends the JSON model to provide additional data types.
MongoDB uses BSON, mainly for efficient encoding and decoding within different languages.
Here are some of the different terminology that are used in the Mongo world.
If you have background of SQL then think table as collection and each row within that table as document.
What is a collection?
A collection is a grouping of MongoDB documents.
So, a collection can holds multiple documents in it .
Each of these document can be in their own form, but usually people put similar documents inside a collection.
In real world, Its very rate to see collection which contains different type of documents in it.
Here is an example that represents a fictional shop.
Here the databse name is SHOP
The database can hold multiple collection in it , just like RDBMS can hold tables in a databse.
In this case The SHOP database has two collections named Users and Orders.
Each of the collection again can hold documents in it.