Getting Started with Relational Databases and SQL

Relational databases organize data into structured tables that can be queried, updated, and managed using SQL, a language designed specifically for working with structured data. This article introduces what a relational database actually is, walks through writing a first SQL query, covers the basic query clauses every database user relies on, and explains the fundamentals of creating and managing tables and their data.

Relational DatabaseSQL BasicsTable Management

~4 min read · Updated Sep 7, 2026

What a Relational Database Actually Is

A Relational Database organizes data into Tables, each consisting of rows and columns, where each row represents one record and each column represents one attribute of that record. This tabular structure, formalized decades ago, remains the dominant way to store structured data because it makes relationships between different kinds of data explicit and queryable.

Example table: customers
| customer_id | name        | email               |
|-------------|-------------|---------------------|
| 1           | Alice Smith | [email protected]   |
| 2           | Bob Jones   | [email protected]      |

A Relational Database Management System (RDBMS) is the software that stores these tables and lets users interact with them — common examples include PostgreSQL, MySQL, and SQLite. Users interact with an RDBMS almost entirely through SQL (Structured Query Language), a specialized language for retrieving and manipulating structured data.

Writing a First SQL Query

The most fundamental SQL statement is SELECT, used to retrieve data from a table.

SELECT name, email
FROM customers
WHERE customer_id = 1;

This query reads naturally: select the name and email columns, from the customers table, where the customer_id equals 1. SQL's design goal is to be declarative — the query describes what data is wanted, not the step-by-step procedure for finding it, leaving the database engine to determine the most efficient way to actually retrieve it.

The Basic Building Blocks of a SQL Query

Beyond a simple `SELECT`, a handful of clauses handle the vast majority of everyday data retrieval needs.

  • WHERE filters rows based on a condition, returning only rows that satisfy it.
  • ORDER BY sorts the returned rows by one or more columns, ascending or descending.
  • LIMIT restricts the number of rows returned, useful for previewing large result sets.
  • GROUP BY groups rows sharing a common value, typically combined with an aggregate function.
SELECT city, COUNT(*) AS customer_count
FROM customers
GROUP BY city
ORDER BY customer_count DESC
LIMIT 5;

This query counts customers per city, sorts cities by that count from highest to lowest, and returns only the top 5 — a pattern extremely common in reporting and analytics tasks.

Managing Tables: Creating Structure

Before any data can be stored, a table's structure must be defined using CREATE TABLE, specifying each column's name and Data Type — the kind of value that column will hold, such as text, integers, or dates.

CREATE TABLE customers (
    customer_id INTEGER PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(100)
);

The PRIMARY KEY designation marks customer_id as the column that uniquely identifies each row — no two rows can share the same value, and this column cannot be left empty. NOT NULL similarly requires that a column always have a value, preventing incomplete records.

Managing Data: Inserting, Updating, and Deleting

Once a table exists, three statements handle changing its contents.

-- Add a new row
INSERT INTO customers (customer_id, name, email)
VALUES (3, 'Carol White', '[email protected]');

-- Modify an existing row
UPDATE customers
SET email = '[email protected]'
WHERE customer_id = 1;

-- Remove a row
DELETE FROM customers
WHERE customer_id = 2;

Each of these statements typically includes a WHERE clause to target specific rows; omitting it from an UPDATE or DELETE would apply the change to every row in the table, a common and costly mistake worth being especially careful about.

Why These Fundamentals Matter

Every more advanced database concept — relationships between tables, normalization, indexing, and performance optimization — builds directly on this foundation of tables, data types, and the core SQL statements introduced here. A solid grasp of how to define a table's structure and reliably query and modify its contents is the prerequisite for everything that follows in database design.

Written & researched by Dr. Shahin Siami

Related Articles

An Overview of Database Design: Goals, Process, and Key Phases

Writing SQL queries is only half the picture; designing a database well before writing any queries at all determines whether that database will remain reliable, efficient, and maintainable as an application grows. This article explains the core goals every database design should pursue, walks through the overall design process from requirements to implementation, and introduces the key phases every well-designed database passes through.

Continue

Connecting Tables: JOINs and More Essential SQL

The real power of a relational database emerges when data is split across multiple related tables instead of being duplicated everywhere. This article explains why splitting data across tables avoids redundancy, covers the foreign key relationship that connects tables together, walks through the different types of JOIN used to query across related tables, and introduces a few more SQL techniques for managing table structure and data safely.

Continue

Set Theory in Relational Databases

Set Theory is the mathematical foundation of the relational database model. Concepts such as Union, Intersection, Difference, and Cartesian Product are directly implemented in SQL. Understanding these concepts helps database engineers write more logical, efficient, and powerful queries. This article explains the relationship between Set Theory and relational databases, the main operations, and practical SQL examples.

Continue

What Are Relational Databases? A Complete Guide to Relational Database Systems

Relational databases are one of the most widely used types of databases that store data in structured tables with defined relationships. By using primary keys, foreign keys, and the SQL language, relational database systems provide reliable, consistent, and efficient data management for modern applications.

Continue