Relational Data Modeling in MySQL
Relational databases excel at organizing complex data without redundancy. Learn First, Second, and Third Normal Forms (1NF, 2NF, 3NF), and how Primary and Foreign Keys enforce referential integrity across tables.
sql Example
-- Creating related tables with Foreign Keys
CREATE TABLE categories (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
category_id INT NOT NULL,
title VARCHAR(150) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
);