Paramclasses Academy - Blog

Tutorials Details

MySQL Primary Key, Foreign Key & Relationships: Database Design for Beginners

MySQL Primary Key, Foreign Key & Relationships: Database Design for Beginners

October 1, 2026

MySQL Primary Key, Foreign Key & Relationships: Database Design for Beginners

Introduction

When you start working with real-world MySQL databases, you will rarely store everything in a single table.

For example, an e-commerce website may have separate tables for:

  • Customers

  • Orders

  • Products

  • Categories

  • Payments

  • Addresses

These tables need to be connected with each other.

For example:

Customer
   ↓
Orders
   ↓
Products

A customer can place multiple orders, and an order can contain a product.

To create these connections properly, MySQL provides concepts such as:

  • Primary Key

  • Foreign Key

  • One-to-One Relationship

  • One-to-Many Relationship

  • Many-to-Many Relationship

These concepts are fundamental to relational database design.

For example:

CREATE TABLE customers (
    id INT PRIMARY KEY,
    name VARCHAR(100)
);

Here, id uniquely identifies each customer.

Then another table can reference that ID:

CREATE TABLE orders (
    id INT PRIMARY KEY,
    customer_id INT,
    amount DECIMAL(10,2),

    FOREIGN KEY (customer_id)
        REFERENCES customers(id)
);

Now the orders.customer_id column is connected to customers.id.

In this tutorial, we will learn:

  • What a Primary Key is

  • Why Primary Keys are important

  • Primary Key examples

  • What a Foreign Key is

  • How Foreign Keys work

  • Creating Foreign Keys

  • Primary Key vs Foreign Key

  • Table relationships

  • One-to-One relationship

  • One-to-Many relationship

  • Many-to-Many relationship

  • Junction tables

  • Real-world e-commerce examples

  • Customer and order relationships

  • Product and category relationships

  • Common beginner mistakes

  • Database design tips

  • Practice exercises

  • Real-world database design challenge


1. What is a Primary Key in MySQL?

A Primary Key is a column, or combination of columns, that uniquely identifies each record in a table.

For example:

customers
id name email
1 Rahul rahul@example.com
2 Amit amit@example.com
3 Priya priya@example.com

Here, id can be the Primary Key.

CREATE TABLE customers (
    id INT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(150)
);

The important point is that every customer should have a unique id.


2. Why Do We Need a Primary Key?

Imagine a customers table:

id name email
1 Rahul rahul@example.com
2 Amit amit@example.com
3 Priya priya@example.com

Suppose we want to update Rahul's information.

We can identify Rahul using:

WHERE id = 1

For example:

UPDATE customers
SET name = 'Rahul Sharma'
WHERE id = 1;

The Primary Key gives us a reliable way to identify exactly one record.

Without a unique identifier, managing records becomes much more difficult.


3. Basic Primary Key Syntax

The simplest syntax is:

CREATE TABLE customers (
    id INT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(150)
);

Here:

id

is the Primary Key.

You can also define the Primary Key separately:

CREATE TABLE customers (
    id INT,
    name VARCHAR(100),
    email VARCHAR(150),
    PRIMARY KEY (id)
);

Both approaches are commonly used.


4. Primary Key Example

Let's create a simple products table.

CREATE TABLE products (
    id INT PRIMARY KEY,
    product_name VARCHAR(150),
    price DECIMAL(10,2)
);

Now insert some products:

INSERT INTO products (id, product_name, price)
VALUES
(1, 'Laptop', 55000),
(2, 'Mobile', 25000),
(3, 'Keyboard', 1500);

The table becomes:

id product_name price
1 Laptop 55000
2 Mobile 25000
3 Keyboard 1500

The id column uniquely identifies each product.


5. Primary Key Must Be Unique

A Primary Key cannot contain duplicate values.

Suppose this record already exists:

id = 1

Trying to insert another record with the same ID:

INSERT INTO products (id, product_name, price)
VALUES (1, 'Monitor', 12000);

will fail because id = 1 already exists.

This prevents multiple records from having the same Primary Key value.


6. Primary Key Cannot Be NULL

A Primary Key is used to identify a record, so it cannot be NULL.

For example:

INSERT INTO products (id, product_name, price)
VALUES (NULL, 'Mouse', 800);

This will fail because the Primary Key cannot be NULL.

So a Primary Key provides a reliable identity for each record.


7. AUTO_INCREMENT with Primary Key

In many applications, IDs are generated automatically.

For example:

CREATE TABLE customers (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(150)
);

Now you don't need to manually provide the ID.

You can insert:

INSERT INTO customers (name, email)
VALUES ('Rahul', 'rahul@example.com');

MySQL automatically generates the ID.

Another customer:

INSERT INTO customers (name, email)
VALUES ('Amit', 'amit@example.com');

The result may look like:

id name email
1 Rahul rahul@example.com
2 Amit amit@example.com

This pattern is extremely common in PHP, Laravel, CodeIgniter and other application development environments.


8. What is a Foreign Key?

A Foreign Key is a column that creates a relationship between two tables by referencing a key in another table.

For example:

customers

id name
1 Rahul
2 Amit
3 Priya

orders

id customer_id amount
101 1 1500
102 2 2500
103 1 3000

Here:

customers.id

is the Primary Key.

And:

orders.customer_id

references it.

Therefore:

customers.id
       ↑
       |
orders.customer_id

The customer_id column is a Foreign Key.


9. Creating a Foreign Key

Let's create the customers table first:

CREATE TABLE customers (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(150)
);

Now create the orders table:

CREATE TABLE orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    customer_id INT,
    amount DECIMAL(10,2),

    FOREIGN KEY (customer_id)
        REFERENCES customers(id)
);

Here:

orders.customer_id

references:

customers.id

This creates a relationship between the two tables.


10. Why Do We Need Foreign Keys?

Imagine an order table containing:

id customer_id amount
101 1 1500
102 2 2500
103 999 3000

If customer ID 999 does not exist, the order points to a non-existing customer.

This creates inconsistent data.

A Foreign Key can help enforce the relationship between the tables.

For example:

customers
ID: 1
ID: 2
ID: 3

orders
customer_id: 1
customer_id: 2
customer_id: 3

The order records refer to valid customer records.


11. Primary Key vs Foreign Key

This is one of the most important differences to understand.

Primary Key Foreign Key
Identifies a record Connects to another table
Must be unique Can contain repeated values
Cannot be NULL May be NULL depending on table design
Usually belongs to its own table References a key in another table
Creates identity Creates relationship

For example:

customers.id

is a Primary Key.

orders.customer_id

is a Foreign Key referencing customers.id.


12. Real-Time Example: Customer and Orders

Consider an e-commerce application.

A customer can place multiple orders.

customers

id name email
1 Rahul rahul@example.com
2 Amit amit@example.com

orders

id customer_id amount
101 1 1500
102 1 3000
103 2 2500

Here:

customers.id

is the Primary Key.

And:

orders.customer_id

is the Foreign Key.

The relationship is:

Rahul → Order 101
Rahul → Order 102
Amit  → Order 103

This is a One-to-Many relationship.


13. What is a Database Relationship?

A database relationship describes how records in one table are connected to records in another table.

Common relationship types are:

  1. One-to-One

  2. One-to-Many

  3. Many-to-Many

Let's understand each with practical examples.


14. One-to-One Relationship

A One-to-One relationship means one record in Table A is associated with one record in Table B.

For example:

One user → One user profile

Suppose we have:

users

id name
1 Rahul
2 Amit

user_profiles

id user_id address
1 1 Delhi
2 2 Mumbai

Each user has one profile.

Relationship:

User 1 → Profile 1
User 2 → Profile 2

15. Creating a One-to-One Relationship

First create the users table:

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100)
);

Then:

CREATE TABLE user_profiles (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT UNIQUE,
    address VARCHAR(255),

    FOREIGN KEY (user_id)
        REFERENCES users(id)
);

The UNIQUE requirement on user_id ensures that the same user cannot have multiple profile records in this design.

Conceptually:

users
  |
  | 1
  |
  | 1
  ↓
user_profiles

16. Real-Time One-to-One Example

One-to-one relationships can be useful when separating sensitive or optional profile information.

For example:

users
----------------
id
name
email

user_profiles
----------------
id
user_id
address
date_of_birth
profile_photo

The main user information is kept in users, while additional profile information is stored separately.

This can make the database structure easier to organize.


17. One-to-Many Relationship

A One-to-Many relationship means one record in one table can be related to many records in another table.

This is one of the most common relationships in database applications.

For example:

One customer → Many orders

A customer can place multiple orders.

customers

id name
1 Rahul
2 Amit

orders

id customer_id amount
101 1 1500
102 1 3000
103 1 5000
104 2 2500

Relationship:

Rahul
 ├── Order 101
 ├── Order 102
 └── Order 103

Amit
 └── Order 104

This is a One-to-Many relationship.


18. Creating a One-to-Many Relationship

CREATE TABLE customers (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100)
);

Then:

CREATE TABLE orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    customer_id INT,
    amount DECIMAL(10,2),

    FOREIGN KEY (customer_id)
        REFERENCES customers(id)
);

The important part is:

FOREIGN KEY (customer_id)
REFERENCES customers(id)

One customer can now be referenced by multiple order records.


19. One-to-Many Real-World Examples

One-to-Many relationships appear everywhere.

Customer → Orders

One customer
      ↓
Many orders

Category → Products

One category
      ↓
Many products

Department → Employees

One department
      ↓
Many employees

Author → Books

One author
      ↓
Many books

Company → Employees

One company
      ↓
Many employees

This is one of the most important relationship patterns in relational databases.


20. Category and Product Relationship

Consider an online store.

categories

id category_name
1 Electronics
2 Accessories

products

id product_name category_id
1 Laptop 1
2 Mobile 1
3 Keyboard 2
4 Mouse 2

Here:

Electronics
 ├── Laptop
 └── Mobile

Accessories
 ├── Keyboard
 └── Mouse

One category has many products.

Therefore:

categories.id
      ↓
products.category_id

21. Many-to-Many Relationship

A Many-to-Many relationship means:

  • One record in Table A can relate to many records in Table B.

  • One record in Table B can also relate to many records in Table A.

For example:

Students ↔ Courses

One student can enroll in multiple courses.

One course can have multiple students.


22. Why Do We Need a Junction Table?

You normally cannot represent a many-to-many relationship cleanly by simply putting one Foreign Key in either table.

Instead, we use a third table called a junction table, also known as a bridge or linking table.

For example:

students
courses
student_courses

The structure becomes:

students
    ↓
student_courses
    ↓
courses

23. Many-to-Many Example

students

id name
1 Rahul
2 Amit
3 Priya

courses

id course_name
1 MySQL
2 PHP
3 JavaScript

student_courses

student_id course_id
1 1
1 2
2 1
2 3
3 1
3 2

This means:

Rahul → MySQL
Rahul → PHP

Amit → MySQL
Amit → JavaScript

Priya → MySQL
Priya → PHP

And:

MySQL → Rahul
MySQL → Amit
MySQL → Priya

So both sides can have multiple relationships.


24. Creating a Many-to-Many Relationship

Create students:

CREATE TABLE students (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100)
);

Create courses:

CREATE TABLE courses (
    id INT AUTO_INCREMENT PRIMARY KEY,
    course_name VARCHAR(100)
);

Now create the junction table:

CREATE TABLE student_courses (
    student_id INT,
    course_id INT,

    PRIMARY KEY (student_id, course_id),

    FOREIGN KEY (student_id)
        REFERENCES students(id),

    FOREIGN KEY (course_id)
        REFERENCES courses(id)
);

The junction table connects students and courses.


25. Why Use a Composite Primary Key Here?

The junction table contains:

student_id
course_id

Together, these two values identify one enrollment.

For example:

student_id = 1
course_id = 2

means:

Student 1 is enrolled in Course 2.

The combination:

(student_id, course_id)

can be used as the Primary Key.

This prevents the same student-course combination from being inserted repeatedly.


26. Real-Time Many-to-Many Example: E-Commerce

Many-to-many relationships are also common in e-commerce.

For example:

Orders ↔ Products

One order can contain multiple products.

One product can appear in many different orders.

A common design is:

orders
order_items
products

For example:

orders

id customer_id
101 1
102 2

products

id product_name
1 Laptop
2 Mouse
3 Keyboard

order_items

order_id product_id quantity
101 1 1
101 2 2
102 2 1
102 3 1

Here:

Order 101
 ├── Laptop
 └── Mouse

Order 102
 ├── Mouse
 └── Keyboard

This is a real-world many-to-many pattern.


27. Primary Key and Foreign Key in an E-Commerce Database

A simple e-commerce database might look like:

customers
    |
    | 1
    ↓
orders
    |
    | many
    ↓
order_items
    |
    | many
    ↓
products

More specifically:

customers
---------
id PK
name
email

orders
---------
id PK
customer_id FK
order_date

order_items
---------
order_id FK
product_id FK
quantity

products
---------
id PK
product_name
price

This structure allows the database to represent real-world relationships efficiently.


28. Relationship Diagram Example

A simple customer-order relationship can be visualized as:

┌──────────────┐
│  customers   │
├──────────────┤
│ id PK        │
│ name         │
│ email        │
└──────┬───────┘
       │
       │ 1
       │
       │ many
       ↓
┌──────────────┐
│    orders    │
├──────────────┤
│ id PK        │
│ customer_id FK│
│ amount       │
│ order_date   │
└──────────────┘

This means:

One customer → Many orders

29. Using Foreign Keys with INSERT

Suppose we have:

CREATE TABLE customers (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100)
);

Insert customers:

INSERT INTO customers (name)
VALUES
('Rahul'),
('Amit');

Now insert an order:

INSERT INTO orders (customer_id, amount)
VALUES (1, 1500);

This order belongs to customer ID 1.

You can insert another order for the same customer:

INSERT INTO orders (customer_id, amount)
VALUES (1, 3000);

Now customer 1 has two orders.

This demonstrates the One-to-Many relationship.


30. Foreign Key and Invalid Data

Suppose customer IDs are:

1
2
3

Now try:

INSERT INTO orders (customer_id, amount)
VALUES (999, 5000);

If the Foreign Key relationship is enforced and customer 999 doesn't exist, MySQL will reject the operation.

This helps prevent invalid references.

The exact behavior can also depend on the table engine and the Foreign Key actions defined.


31. ON DELETE with Foreign Keys

Foreign Keys can define what happens when a referenced record is deleted.

For example:

CREATE TABLE orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    customer_id INT,
    amount DECIMAL(10,2),

    FOREIGN KEY (customer_id)
        REFERENCES customers(id)
        ON DELETE CASCADE
);

ON DELETE CASCADE means that deleting a customer can automatically delete related order records.

For example:

Delete Customer 1
       ↓
Related orders for Customer 1
       ↓
Deleted automatically

However, this behavior should be chosen carefully because deleting a parent record can cause related data to be deleted.


32. ON DELETE SET NULL

Another option is:

ON DELETE SET NULL

Example:

CREATE TABLE orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    customer_id INT NULL,
    amount DECIMAL(10,2),

    FOREIGN KEY (customer_id)
        REFERENCES customers(id)
        ON DELETE SET NULL
);

If the customer is deleted, the related customer_id can become NULL instead of deleting the order.

This can be useful when the order history needs to remain available even after the customer record is removed.


33. ON UPDATE CASCADE

You may also see:

ON UPDATE CASCADE

For example:

FOREIGN KEY (customer_id)
REFERENCES customers(id)
ON UPDATE CASCADE

This tells MySQL to propagate an update to the referenced key to related Foreign Key values.

In modern application design, Primary Key values are often treated as stable identifiers, so updates to them are relatively uncommon.


34. Real-Time Example: Department and Employees

Consider a company database.

departments

id department_name
1 IT
2 HR
3 Sales

employees

id name department_id
101 Rahul 1
102 Amit 1
103 Priya 2
104 Neha 3

Relationship:

IT
 ├── Rahul
 └── Amit

HR
 └── Priya

Sales
 └── Neha

One department can have many employees.

Therefore:

departments.id
       ↓
employees.department_id

35. Real-Time Example: User and Profile

Consider a website where user login information and profile information are stored separately.

users

id
name
email
password_hash

user_profiles

id
user_id
phone
address
profile_photo

Relationship:

One User
   ↓
One Profile

This is a One-to-One relationship.

Example:

CREATE TABLE user_profiles (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT UNIQUE,
    phone VARCHAR(20),
    address VARCHAR(255),

    FOREIGN KEY (user_id)
        REFERENCES users(id)
);

36. Real-Time Example: Blog and Categories

Suppose you are creating a blog website.

A blog post belongs to one category.

A category can contain many posts.

categories
    ↓
posts

For example:

Technology
 ├── MySQL Tutorial
 ├── PHP Tutorial
 └── CodeIgniter Tutorial

Travel
 ├── Delhi Travel Guide
 └── Mumbai Travel Guide

This is a One-to-Many relationship.

Possible database structure:

categories
-----------
id PK
name

posts
-----------
id PK
category_id FK
title
content

37. How to Identify Relationships

When designing a database, ask simple questions.

Question 1

Can one customer have multiple orders?

Yes.

Therefore:

Customer → Orders
One-to-Many

Question 2

Can one user have only one profile?

If your application design requires one profile per user:

User → Profile
One-to-One

Question 3

Can a student enroll in multiple courses?

Yes.

Can a course contain multiple students?

Yes.

Therefore:

Students ↔ Courses
Many-to-Many

This simple question-based approach makes relationship design easier.


38. Primary Key and Foreign Key Naming Convention

A common naming pattern is:

Parent table:
id

Child table:
parent_id

For example:

customers
id

orders
customer_id

Another example:

categories
id

products
category_id

Another:

departments
id

employees
department_id

This naming convention makes relationships easier to understand.


39. Common Beginner Mistakes

Mistake 1: Using Duplicate Primary Keys

Incorrect:

INSERT INTO customers (id, name)
VALUES
(1, 'Rahul'),
(1, 'Amit');

Both records use the same Primary Key.

Use unique IDs instead.


40. Mistake 2: Confusing Primary Key and Foreign Key

Remember:

Primary Key
→ Identifies the record

Foreign Key
→ References another table

Example:

customers.id
→ Primary Key

orders.customer_id
→ Foreign Key

41. Mistake 3: Creating a Foreign Key to the Wrong Column

Suppose:

customers.id

is the identifier.

The order table should reference the appropriate key:

FOREIGN KEY (customer_id)
REFERENCES customers(id)

Always make sure the referenced column represents the intended relationship.


42. Mistake 4: Trying to Store Multiple IDs in One Column

A beginner might create:

product_ids = "1,2,5,8"

inside one column.

This is usually a poor relational design.

Instead, use a separate table such as:

order_items

For example:

order_id product_id
101 1
101 2
101 5
102 2

This properly represents the relationship between orders and products.


43. Mistake 5: Not Understanding the Relationship Type

Before creating tables, determine whether the relationship is:

One-to-One
One-to-Many
Many-to-Many

For example:

Customer → Orders

is usually One-to-Many.

While:

Students ↔ Courses

is Many-to-Many.

Correctly identifying the relationship makes the database structure much easier to design.


44. Primary Key and Foreign Key Quick Reference

Primary Key

id INT PRIMARY KEY

Used to uniquely identify a record.

Auto-generated Primary Key

id INT AUTO_INCREMENT PRIMARY KEY

MySQL automatically generates the ID.

Foreign Key

FOREIGN KEY (customer_id)
REFERENCES customers(id)

Connects one table to another.

One-to-One

User → Profile

One record relates to one record.

One-to-Many

Customer → Orders

One record relates to many records.

Many-to-Many

Students ↔ Courses

Both sides can have many related records.

Usually requires a junction table.


45. Relationship Comparison

Relationship Example Typical Design
One-to-One User → Profile Foreign Key + uniqueness
One-to-Many Customer → Orders Foreign Key in child table
Many-to-Many Students ↔ Courses Junction table

Easy way to remember:

1 : 1
One user → One profile

1 : N
One customer → Many orders

N : N
Many students ↔ Many courses

46. Practical Database Design Example

Imagine you are building an online shopping website.

You need these features:

Customers
Products
Categories
Orders
Order Items

A simple database design could be:

categories
    |
    | 1
    ↓
products
customers
    |
    | 1
    ↓
orders
    |
    | 1
    ↓
order_items
    |
    | many
    ↓
products

More precisely:

customers
---------
id PK
name
email

categories
---------
id PK
name

products
---------
id PK
category_id FK
product_name
price

orders
---------
id PK
customer_id FK
order_date
status

order_items
---------
order_id FK
product_id FK
quantity
price

This is much more scalable than putting all information into one giant table.


47. Practical Database Design Challenge

Imagine a company wants to build an employee management system.

Requirements:

  • One department can have many employees.

  • Each employee belongs to one department.

  • Each employee can have one profile.

  • Employees can participate in multiple projects.

  • Each project can have multiple employees.

Think about the relationships.

Department → Employees

One-to-Many

Employee → Profile

One-to-One

Employees ↔ Projects

Many-to-Many

A possible design is:

departments
-----------
id PK
name

employees
-----------
id PK
department_id FK
name

employee_profiles
-----------
id PK
employee_id FK
phone
address

projects
-----------
id PK
name

employee_projects
-----------
employee_id FK
project_id FK

This example demonstrates all three major relationship types.


48. Practice Exercises

Try solving these database-design problems yourself.

Exercise 1

Create a students table with:

id
name
email

Make id the Primary Key.

-- Write your query here

Exercise 2

Create a courses table with:

id
course_name

Make id the Primary Key.

-- Write your query here

Exercise 3

Create a student_courses table for a Many-to-Many relationship.

It should contain:

student_id
course_id
-- Write your query here

Exercise 4

Create a customers table and an orders table with a One-to-Many relationship.

-- Write your query here

Exercise 5

Create a One-to-One relationship between:

users
user_profiles
-- Write your query here

Exercise 6

Create:

categories
products

where one category can have many products.

-- Write your query here

Exercise 7

Design a database for:

Authors
Books

Assume one author can write multiple books.

Identify:

  • Primary Key

  • Foreign Key

  • Relationship type

Exercise 8

Design a database for:

Students
Courses

Assume students can enroll in multiple courses and each course can contain multiple students.

Identify the junction table you would use.


49. Important Things to Remember

Before moving to the next MySQL topic, remember these points:

  1. A Primary Key uniquely identifies a record.

  2. Primary Key values cannot be duplicated.

  3. A Primary Key cannot be NULL.

  4. AUTO_INCREMENT can automatically generate numeric IDs.

  5. A Foreign Key connects one table to another.

  6. A Foreign Key usually references a key in another table.

  7. One-to-One means one record is related to one record.

  8. One-to-Many means one record can be related to many records.

  9. Many-to-Many means both sides can have multiple related records.

  10. Many-to-Many relationships generally use a junction table.

  11. customer_id in an orders table is a common Foreign Key pattern.

  12. Primary and Foreign Keys help create structured relational databases.

  13. Correctly identifying relationships is important before creating tables.

  14. Avoid storing lists of IDs as comma-separated values in one column when a relational table can represent the relationship properly.


Conclusion

Primary Keys, Foreign Keys, and relationships are fundamental concepts in MySQL database design.

A Primary Key identifies a record:

id INT PRIMARY KEY

A Foreign Key connects related tables:

FOREIGN KEY (customer_id)
REFERENCES customers(id)

And relationships describe how tables are connected:

One-to-One
One user → One profile
One-to-Many
One customer → Many orders
Many-to-Many
Many students ↔ Many courses

For a real-world e-commerce application, you might have:

customers
    ↓
orders
    ↓
order_items
    ↓
products

with categories connected to products.

Understanding these concepts helps you move from simple database tables to properly structured relational databases.

These concepts are especially important when developing:

  • E-commerce websites

  • CRM applications

  • School management systems

  • Employee management systems

  • Banking applications

  • Inventory systems

  • PHP applications

  • CodeIgniter applications

  • Admin dashboards

  • Enterprise applications

Once you understand Primary Keys, Foreign Keys, and relationships, the next step is learning how to modify database structures safely.


Next MySQL Tutorial

In the next tutorial, we will learn:

MySQL ALTER, TRUNCATE, DROP & Database Structure Management

We will learn how to modify existing tables, add or remove columns, change column definitions, remove table data, and understand the difference between ALTER, TRUNCATE, and DROP with practical examples.