Skip to content
Home Tutorials Roadmaps Courses Classroom Training Blog
Log in Join free
Computer Science Beginner Free

Relational Databases

Lesson 8 of 17 · Database Concepts 47%
1. Introduction to CS
What is Computer Science?
6. Operating Systems
OS Fundamentals
7. Cybersecurity Basics
Security Fundamentals
8. Software Engineering
Software Development Life Cycle
9. Cloud Computing
Cloud Computing Basics
10. Dynamic Programming
Dynamic Programming Introduction
11. AI & Machine Learning
Introduction to AI & ML
12. Internet of Things
IoT Fundamentals
13. Blockchain Basics
How Blockchain Works

Relational databases organize data into tables with rows and columns, linked by keys.

Syntax

COMPUTER-SCIENCE
CREATE TABLE users (
    id INT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(100) UNIQUE
);

CREATE TABLE orders (
    id INT PRIMARY KEY,
    user_id INT,
    FOREIGN KEY (user_id) REFERENCES users(id)
);
SQL JOIN Types
SQL
-- INNER JOIN
SELECT users.name, orders.amount
FROM users
INNER JOIN orders ON users.id = orders.user_id;

-- LEFT JOIN (all users, even without orders)
SELECT users.name, COALESCE(SUM(orders.amount), 0) AS total
FROM users
LEFT JOIN orders ON users.id = orders.user_id
GROUP BY users.name;

-- Subquery
SELECT name FROM users
WHERE id IN (SELECT user_id FROM orders WHERE amount > 100);

Practice

1
Exercise

What is a foreign key?

Answer
A column in one table that references the primary key of another table, creating a relationship.

Quick Quiz

1

What does SQL stand for?

SQL stands for Structured Query Language.

Choose an answer to continue.

Interview Questions

Atomicity, Consistency, Isolation, Durability — properties that guarantee reliable database transactions.

Up next

NoSQL Databases

Lesson 9 of 17 · Database Concepts