What is a database?

A Database is a service designed to store, organize, and retrieve large volumes of data efficiently. It is NOT just a data store; it is usually the most critical component of any application.

Technically, what we usually use is a DBMS, which stands for Database Management System.
This is nothing more than an intermediary between the applications and the data, allowing applications to save and extract data without issues.

Why don’t we save everything in text files?

Being able to separate the computation logic from the data layer is one of the best practices you can follow in the programming world. Additionally, it is done for the following reasons:

  • Persistence: Data survives even if the program closes or the server restarts.
  • Concurrency: Allows thousands of users to read and write information at the same time without data corruption.
  • Efficiency: It would be extremely costly and complex to develop a storage system from scratch for every project. By using existing databases, we reuse technology optimized over decades.

What types of databases exist?

Not all data is equal, so there are different ways to organize it:

  • SQL Databases (Relational): They organize information in tables with rows and columns (similar to an advanced Excel but linked). They are ideal for data with fixed structures and where integrity is the most important factor.
    • Examples: PostgreSQL (robust and standard in Data Science) and MySQL (very common in the traditional web).
  • NoSQL Databases (Non-Relational): They do not use fixed tables, but rather documents or graphs. They are perfect for projects that scale massively or where the data structure changes constantly.
    • Examples: MongoDB, Cassandra, or Redis.
  • NewSQL: A modern evolution that attempts to combine the scalability of NoSQL with the integrity of SQL.

What is used to communicate programs with the database?

The languages used are:

  • SQL (for relational databases)
    It is the gold standard for Relational databases. It is based on relational algebra and its syntax is declarative: you tell the system what you want, and the database engine decides how to get it.
    • Usage: PostgreSQL, MySQL, SQL Server.
    • Syntax example:
      SELECT name, surname FROM students WHERE average >= 8,5;
    • Key point: It is extremely rigid; if the data does not comply with the table schema, it is not saved.
  • NoSQL: Diversity of languages
    In the NoSQL world, there is no single standard language, as each database adapts to a different structure:
    • Document-Oriented (JSON/BSON): Like MongoDB. They do not use a text language like SQL, but are queried via objects.
      • Example: db.users.find({ age: { $gt: 18 } }).
    • Graph-Oriented: Like Neo4j. They use languages like Cypher, designed to traverse relationships between nodes (widely used in social networks to see “friends of friends”).
  • CQL (Cassandra Query Language)
    If you are going to mention Cassandra (a “Column-family” type NoSQL database), it is essential to talk about CQL.
    • What is it?: It is the language of the Apache Cassandra database.
    • The resemblance to SQL: At first glance, it looks like SQL, which is an advantage for engineers because the learning curve is low.
    • The technical difference: Unlike SQL, CQL does not allow “Joins” (table unions) or complex subqueries. It is designed to be massively scalable across server clusters, sacrificing relational flexibility for incredible write speed.
LanguageDB TypeData StructureScalability
SQLRelationalFixed TablesVertical (More hardware)
MQL / JSONDocumentFlexible DocumentsHorizontal (More servers)
CQLWide ColumnDynamic ColumnsMassive Horizontal
CypherGraphsNodes and RelationshipsSpecialized in connections

Leave a Reply

Your email address will not be published. Required fields are marked *