CodeGym /Courses /SQL SELF /Types of DBMS: Relational and NoSQL

Types of DBMS: Relational and NoSQL

SQL SELF
Level 1 , Lesson 2
Available

There are two main types of DBMS (Database Management System): relational and NoSQL. The first ones work with tables, where everything is neat and by columns — like in Excel. The second ones are more chill, they don't need a strict structure. That's handy when you don't have a clear data schema or it keeps changing all the time.

By the way, NoSQL doesn't mean "no SQL." It's more like "not only SQL" (Not Only SQL). A lot of NoSQL systems actually understand SQL queries, they just work a bit differently.

Examples of popular DBMS:

  • Relational: PostgreSQL, MySQL, Microsoft SQL Server.
  • NoSQL: MongoDB, Cassandra, Redis.

Relational DBMS

A relational database (RDB) organizes data as tables, where each row is a separate record (or object), and each column is a field (attribute). Tables are linked together using keys: primary (to identify a record) and foreign (to connect tables).

Here's a classic example of a "Students" table in a relational DBMS:

id name age group
1 Anna 21 KA-01
2 Eve 20 KA-02
3 Max 22 KA-01

Key features of relational DBMS:

  • Data is strictly structured.
  • Relationships between tables are defined using keys.
  • SQL (Structured Query Language) is used to work with the data.

Advantages

  1. Strict data structure: tables make sure every object has a fixed set of fields. That makes managing data easier.
  2. Data integrity: thanks to primary and foreign keys, relational DBs prevent mismatches in data sets.
  3. ACID standard support: relational DBMS guarantee reliable transactions, following the principles of atomicity, consistency, isolation, and durability.
  4. Support for complex queries: SQL lets you do powerful selects, sorting, and aggregation.

Relational DBMS are perfect when your data is super structured and it's important that everything matches down to the last digit. For example, in banking systems, you can't afford to lose anything — every account movement has to be tracked. Or, say, in accounting systems: invoices, clients, and warehouses usually have a fixed structure, and it's convenient to store them as tables. And of course, in lots of web apps, where you have, for example, a list of users, products, orders — all of that fits perfectly into tables and strict relationships.

NoSQL DBMS

NoSQL (Not Only SQL) — these are DBMS that don't use the relational model. Data can be stored as documents, in key-value format, graphs, or columns. The idea is flexibility: you can store data however works best for your task, without strict rules. And you pay the price for that, of course.

Example of storing data in NoSQL (for MongoDB):

{
  "id": 1,
  "name": "Alex",
  "age": 21,
  "group": "KA-01"
}

NoSQL DBMS can be really different — depending on how exactly they store data. For example, document DBMS like MongoDB work with flexible structures, where data is saved as documents, usually in JSON format. That's handy if your data structure can change from record to record.

Key-value DBMS, like Redis, are basically huge storages of "key:value" pairs. They're perfect for caches or fast access to simple settings.

If you need to work with relationships between objects — like analyzing friends in a social network or building routes — you'll want graph DBMS like Neo4j. They store info as a network of nodes and relationships, which is super handy for those kinds of structures.

And then there are column DBMS like Apache Cassandra or HBase, which store data by columns, not rows. That's especially useful if you're working with huge amounts of data and need to quickly analyze just certain metrics — like in analytics or Big Data systems.

Why and when should you pick NoSQL

NoSQL databases are awesome where traditional relational DBMS start to choke. They've got a few strong points:

  1. They're fast. NoSQL handles huge amounts of data like a champ — queries are quick, even if the data is massive and not structured like an Excel table.
  2. Flexible. You can change the data structure on the fly: today an object has three fields, tomorrow — five, and nothing breaks.
  3. Easy to scale. When you get too much data, you can just spread it across different servers. That's called horizontal scaling, and NoSQL loves it.
  4. Works great with Big Data. If you've got a stream of logs, events, user actions, or other "raw" data with no clear schema — NoSQL can handle it.

These DBMS are especially good when:

  • the amount of data is growing fast and the structure keeps changing (like log or event analysis),
  • you need to search and aggregate info quickly (like in analytics),
  • you're dealing with a complex network of relationships, like in social networks (graph DBMS are perfect for this).

Long story short, if your project is more like a living organism than a strict table, NoSQL might be just what you need.

Comparing Relational and NoSQL DBMS

Characteristic Relational DBMS NoSQL DBMS
Data storage Tables, rows, columns Documents, graphs, key-value, columns
Query language SQL Depends on implementation (like MongoDB Query)
Data integrity High (primary/foreign keys) Depends on implementation (integrity not guaranteed)
Scalability Vertical (beefing up the server) Horizontal (spreading across servers)
Structure flexibility Rigid structure (tables and fields are fixed) Dynamic structure (can change)
Performance Optimal for structured data High with big volumes and loosely structured data
Examples PostgreSQL, MySQL, Oracle Database MongoDB, Cassandra, Redis

When to pick Relational or NoSQL DBMS?

Relational DBMS:

  • When your data is strictly structured.
  • When you need transaction support.
  • When you need complex analytics via SQL.

NoSQL DBMS:

  • When you need flexibility in your data structure.
  • When scalability is more important than strict structure.
  • When you need to work with huge amounts of data that are hard to organize into tables.

You can think of it like this: imagine a relational DBMS as an Excel table, where everything is perfect by rows and columns. And NoSQL — that's like a pinboard where you can stick anything, from notes to photos.

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION