Inside the Stack Logo
Loading the Stack...

Data & Databases: Storage and Retrieval

A database is the organized collection of data that gives an application its memory. It allows the backend to store, retrieve, and manage all persistent information.

Why Do We Need Databases?

The server's business logic needs a place to store information that must persist beyond a single user session. Databases manage this persistent storage, handling everything from user accounts and preferences to massive product catalogs and financial transactions.

The Data Schema

A schema is the blueprint of a database—it defines the structure, organization, and relationships between tables or collections of data. A good schema ensures data integrity and efficient retrieval.

SQL: Structured Query Language

SQL is the universal language used to communicate with Relational Databases (RDBMS), such as SQL Server, MySQL, PostgreSQL, and SQLite. These databases are based on tables with predefined columns and strict relationships (like linking a customer to an order).

Example SQL Query

SELECT username, email
 FROM Users
 WHERE active = TRUE;

SQL is ideal when your data needs to be consistent and highly structured (e.g., banking, e-commerce orders).

NoSQL: Not Only SQL

NoSQL databases are designed for flexibility and scale, often handling massive amounts of unstructured data. They do not rely on rigid schemas or traditional tables.

  • Document (e.g., MongoDB): Stores data in flexible, JSON-like documents. Ideal for rapid development and data that changes frequently.
  • Key-Value (e.g., Redis): Stores simple key-value pairs. Used primarily for caching and fast lookup.
  • Graph: Used to map complex relationships between data points (e.g., social networks).

Choosing a Database

The choice depends on the application's needs:

  • SQL (Relational): Best for applications where data relationships are fixed and integrity is paramount.
  • NoSQL (Non-Relational): Best for applications that need high scalability, flexibility, and handle unstructured data (e.g., logging, content management).

The server has logic and storage. Now, how does the Frontend talk to it all?

Continue to APIs & Communication →