What even is MongoDB?

Roger Siver
2 min readApr 26, 2021

According to the creators, it’s “a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.” This is extremely scary to someone new to programming who hasn’t had a task that required the use of a server or database in my limited experience. However, it’s coming up, and I feel the need to familiarize myself. I had a handful of questions going in. I pared it down to the ones I would like to share with other beginners to help maybe get their first foothold in the deeps of database design.

1: How can I tell where I’m storing data?

So I tried to do a test run of MongoDB with a basic tutorial that I found here. (https://codeburst.io/build-a-todo-app-with-react-and-node-part-2-frontend-faf0b04ab4f2);

The first problem I ran into was created because I assumed that MongoDB was included in a project as an API added and that the data was going to be stored somewhere along with your other code for easy access. Npm install MongoDB gives your js app the ability to communicate with a MongoDB server, it does not make your application a MongoDB server. This is its own process. A quick google search of “where is my MongoDB” returns that it’s definitely on the root folder of your computer. Why is this?: MongoDB is a service that is running on your device, communicated with via your code. That’s why it stores all of its data in a db folder that you can of course define yourself, but defaults to the root, as it is the easiest place for the service to access. I realize in most cases this will be a dedicated device or at least a virtual machine on the cloud that acts as a dedicated device.

2: What is the difference between relational/nonrelational data?

This one is a little more simple. Relational Data is a table, nonrelational data is a collection of lists of information. Imagine a doctor's office with hundreds of patients. If a patient has 30 prescriptions, with a table, an adjacent patient with one prescription would have 29 empty prescription fields taking up space on the table. This quickly becomes unreadable and inefficient. MongoDBs non-relational, nonstructured styling would save every patient as its own “document”, in the Patients “collection”. (https://www.youtube.com/watch?v=EE8ZTQxa0AM&t=1s) This will save on all empty space created by a relational structure and allow us to just save each person’s information, however much necessary, in their “document”. There are times when relational databases are necessary, like if you have to often perform actions on an entire row or column of your table.

After this research completed, and these two basic concepts understood, I feel much more able to tackle my first NoSQL database task!

--

--