codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🏗️

System Design

12 / 49 topics
11Database Design12Relational Databases13Non-Relational Databases14Data Modeling
Tutorials/System Design/Relational Databases
🏗️System Design

Relational Databases

Updated 2026-05-15
10 min read

Relational Databases

Introduction

In the world of data management, relational databases are a fundamental technology. They provide a structured way to store and manage data, making it easier to retrieve, update, and maintain. This tutorial will introduce you to the basics of relational databases and SQL (Structured Query Language), which is used to interact with these databases.

Concept

A relational database is a collection of related tables that are linked together using common fields. Each table consists of rows and columns, where each row represents a record, and each column represents a field or attribute of the record. The relationship between tables is defined by keys: primary keys and foreign keys.

  • Primary Key: A unique identifier for each record in a table.
  • Foreign Key: A field in one table that references the primary key of another table, establishing a link between them.

Tables

Tables are the basic unit of data storage in a relational database. Each table has a specific structure defined by its columns, and each column has a name and a data type.

SQL (Structured Query Language)

SQL is the standard language used to manage and manipulate relational databases. It allows you to perform various operations such as creating tables, inserting data, querying data, updating records, and deleting records.

Basic SQL Commands

  • CREATE TABLE: Used to create a new table.
  • INSERT INTO: Used to insert new rows into a table.
  • SELECT: Used to query data from one or more tables.
  • UPDATE: Used to update existing records in a table.
  • DELETE: Used to delete records from a table.

Examples

Let's walk through some practical examples to understand how relational databases and SQL work.

Creating a Table

First, let's create a simple table named students with columns for id, name, and age.

SQL
1CREATE TABLE students (
2 id INT PRIMARY KEY,
3 name VARCHAR(100),
4 age INT
5);

Inserting Data

Next, let's insert some data into the students table.

SQL
1INSERT INTO students (id, name, age) VALUES
2(1, 'Alice', 20),
3(2, 'Bob', 22),
4(3, 'Charlie', 21);

Querying Data

To retrieve data from the students table, you can use the SELECT statement.

SQL
1SELECT * FROM students;

The output will be:

Output
id | name    | age
---|---------|-----
1  | Alice   | 20
2  | Bob     | 22
3  | Charlie | 21

Updating Data

To update a record in the students table, use the UPDATE statement.

SQL
1UPDATE students SET age = 23 WHERE id = 1;

Deleting Data

To delete a record from the students table, use the DELETE statement.

SQL
1DELETE FROM students WHERE id = 2;

What's Next?

Now that you have a basic understanding of relational databases and SQL, you might want to explore more advanced topics such as:

  • Indexes: To improve query performance.
  • Joins: To retrieve data from multiple tables.
  • Normalization: To reduce redundancy and improve data integrity.

PreviousDatabase DesignNext Non-Relational Databases

Recommended Gear

Database DesignNon-Relational Databases