What is MongoDB?

A free video tutorial from Academind by Maximilian Schwarzmüller
Online Education
45 courses
2,638,575 students
Lecture description
Let's dive into the most important question: What is MongoDB? What is it all about? MongoDB is a NoSQL database and in this lecture, we'll explore why it's awesome!
Learn more from the full course
MongoDB - The Complete Developer's Guide 2023
Master MongoDB Development for Web & Mobile Apps. CRUD Operations, Indexes, Aggregation Framework - All about MongoDB!
17:29:23 of on-demand video • Updated May 2023
Learn what document databases are and how data is organized with MongoDB
Learn how to perform CRUD operations with MongoDB
Don't stop at the basics - learn all about writing complex MongoDB queries, in-depth and with practical examples!
Write efficient and well-performing queries to fetch data in the format you need it
Use all features MongoDB offers you to work with data efficiently
English
So what is mongodb? Mongodb is most importantly, a database. It's a database but the company behind mongodb which is focused on that database and a couple of other products which I'll also talk about in this course, so the company behind that is also called mongodb but with mongodb, I of course mean the database. Now the name is stemming from the word humongous because this database is built to store lots and lots of data and not just from a data size perspective but also in a sense of you can store lots of data and you can then work with it efficiently which of course also is super important, so this is mongodb, it's a database solution. 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? Well mongodb of course also is most importantly a database server that allows you to then run different databases on it, so we might have a shop database running on our mongodb server because the mongodb environment basically gives you a server which you start and which you can then create multiple databases using mongodb. So we have a shop database, in the mySQL world, we also have databases and in such a database, we would have tables, in mongodb we have so-called collections, so in our shop, we might have a users and an orders collection, we probably would also have a products collection but this is just an example of course, so we have these collections inside our database and you can have multiple databases and multiple collections per database. Now inside of a collection, you have so-called documents which look like this, now these documents if you are having a javascript background might look familiar to you, they look like javascript objects and indeed this is basically how you store data in mongodb, you use this document format, this object format as you know it from javascript and you might even notice here that inside a collection, you are schemaless, this second document does not look like the first one, the age is missing and this is a flexibility mongodb gives you. It is really all about flexibility, where SQL based databases are very strict about the data you have to store in there, mongodb is more flexible, you can store totally different data in one and the same collection and therefore, your database can grow with your application and your application needs. Of course, typically you will have some kind of structure in one collection because your app typically requires some type of structure to work with the data and in this course, we'll actually have a whole module where I talk just about data structures and relations, where I will make it clear how you can structure it, how you can follow best practices, how you want to structure different related data and so on but you are schemaless and that is one important thing. Now inside a document as I mentioned, you use these javascript objects to store your data, to be precise, you use a format called json and this is how a document would look like. In json, a single document is surrounded by these curly braces and you will see that once we start working with it and then we have our keys in there, so that would be a key and key consists of a name of that key here, which has to be surrounded in double quotation marks so name, age, address and hobbies would be key names here or also keys, I'll also refer to them as just keys, then we have a colon and then we have the value of that key. So here we have Max which would be some text string and therefore also has to be enclosed in double quotation marks but you can also store numbers without quotation marks then, you could store booleans, true or false and you can even store nested data as you can see. The address key or field as you could also call it has an embedded document, so this again has curly braces in there and then another key value pair. And this is another cool feature of mongodb and it's documents, you can store nested data in there and why is that helpful? Well this allows you to create complex relations between data and store them in one and the same document which makes working with it and fetching it super efficient, where in SQL, you have to write complex joins to find data in table A and data in table B, here you can fetch it all in one document and you're good to go, so this is highly efficient and allows you to store data in a logical way. Hobbies shows you another example of data you can store in a document, here we have a list of embedded documents and you could also have a list of strings or numbers, so storing list is also possible and this altogether is in one document inside a collection. Now in title it also says bson instead of json, well behind the scenes on the server, mongodb converts your json data which is this format you see here to a binary version of it which can basically be stored and can queried more efficiently, you don't need to worry about that, we work with this json something, we work with this object thing throughout the course. So this is the data we store, this is a document and the whole theme of this video and of mongodb really is the flexibility and the optimisation for usability and that is really what sets mongodb apart from other database solutions and which makes it so awesome and so efficient from a performance perspective too because you can query data in the format you need it instead of running complex restructurings on the server.