All companies store data. Whether it is small business storing their record book or a massive company like Google that has petabytes of user data. A database is a collection of data — numbers, dates, password hashes. DB allows us to organize the data in a way that is useful to us. DBMS is a collection of programs that allow users to access DBS and work with data. There are two types of databases that are really popular right now and they are Postgres (relational) and MongoDB(non-relational).

Relational DBs are the most popular.

Relational DBs consist of 2 or more tables with columns and rows. Each row represents an entry and each column stores a specific type of info like name, address, or phone number. The relation between tables and fields is called a schema. The schema must be clearly defined before any information can be added.

All relational DB’s use something called SQL to communicate with the server.

The second type of DB is called a non-relational DB or NoSQL.

A non-relational DB like MongoDB lets you build a DB without having to define the schema. They act more like folders — assembling related information of all types. MongoDB is document-oriented i.e. stores info as documents. As illustrated below.

Image of storage of the relational database

Mongo DB stores each user as a document and containers all information about the user such as tweets followers etc inside that document.

IS ONE BETTER THAN THE OTHER?

Not necessarily, it depends on your needs. The non-relational way seems good if you have something like a Linkedin profile but if you need something where you are working with more complex systems such as tweets and followers where you want to examine tweet size it is easier to do that relationally.

MongoDB has its own query language called MongoDB Query language which it uses to communicate with the server. The structure of MongoDb can be thought of as a JSON object.

Full Stack Engineer — THIS CODE IS ON FIRE!!!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store