Relational databases organize data into tables with rows and columns, linked by keys.
Introduction to CS
What is Computer Science?
Operating Systems
OS Fundamentals
Cybersecurity Basics
Security Fundamentals
Software Engineering
Software Development Life Cycle
Cloud Computing
Cloud Computing Basics
Dynamic Programming
Dynamic Programming Introduction
AI & Machine Learning
Introduction to AI & ML
Internet of Things
IoT Fundamentals
Blockchain Basics
How Blockchain Works
Computer Science
Beginner
FREE
Relational Databases
Lesson 1 of 17
Beginner
Interactive
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.
Interview Questions
Atomicity, Consistency, Isolation, Durability — properties that guarantee reliable database transactions.