Are there different types of databases?




Are there different types of databases?


Yes, there are, generally, they are divided into two: SQL and NoSQL databases. SQL stands for Structured Query Language which resembles a lot to English. if you were to add something to a database of users, for example, this will look something like:

INSERT INTO Users_Table (name, email, favorite_color)
VALUES ('axel', '', 'green');

There we are simply inserting a whole set of values that will comprise one user into the table named Users_Table.

Another detail about SQL databases is that they are indexed, so each item will have a unique identifier, which has earned them the name of relational databases, whereas NoSQL databases do not need to keep indexes or even be related to one single table, for example, we work with MongoDB through Mongoose, which is a document based database and provides more flexibility to write and edit the schema, adding a document in MongoDB using Mongoose can be simple using the model:

/*create how the document will be arranged*/

const usersSchema = new mongoose.schema({ name: 'String', email: 'String', favorite_color: 'String'});

//setting a model is like creating a table or folder where to keep the documents
const Users = mongoose.model('users', usersSchema);

//add a document
Users.create('axel', '', 'green');

From there, any other type of database is closely related to one of these two, for example, Object Related Databases are like SQL, and Graph Databases are a kind of NoSQL database.

As we grow as developers, we will interact with many of these options to being flexible and understanding them well is important.