diff --git a/docs/sql/SQL-basics/assets/32-primary-foreign-key-example.png b/docs/sql/SQL-basics/assets/32-primary-foreign-key-example.png
new file mode 100644
index 00000000..90a0373c
Binary files /dev/null and b/docs/sql/SQL-basics/assets/32-primary-foreign-key-example.png differ
diff --git a/docs/sql/SQL-basics/constraints.md b/docs/sql/SQL-basics/constraints.md
new file mode 100644
index 00000000..eb1a70d9
--- /dev/null
+++ b/docs/sql/SQL-basics/constraints.md
@@ -0,0 +1,158 @@
+---
+id: sql-constraints
+title: SQL Constraints
+sidebar_label: SQL Constraints
+sidebar_position: 6
+tags: [sql, constraints, database, relational-databases]
+description: In this super beginner-friendly guide, you’ll learn about SQL constraints—rules that keep your database data safe, accurate, and organized!
+keywords: [sql, constraints, sql tutorial, sql basics, database management, relational databases, sql constraints tutorial, sql for beginners, sql in 2025]
+---
+
+## 📙 Welcome to SQL Constraints!
+
+Hey there, new SQL learner! Imagine you are organizing a big toy box, and you want to make sure no toy gets lost or mixed up. Constraints are like special rules you set for your database tables to keep everything in order. They help stop mistakes, like adding a negative age or leaving a name blank. We’ll use a `students` table (with columns like `id`, `name`, and `age`) to show you how it works, step by step!
+
+### 📘 What Are Constraints?
+
+Constraints are like guardrails for your data. They are rules you add to columns in a table to:
+- Stop invalid data (e.g., no negative ages like -5).
+- Make sure some data is unique (e.g., no two students with the same ID).
+- Keep everything consistent across your database.
+
+There are several types of constraints, like NOT NULL, UNIQUE, CHECK, and DEFAULT. Let’s explore each one with easy examples!
+
+> **Pro Tip**: Adding constraints when you create a table is a smart way to catch mistakes early—think of it as setting up rules before the game starts!
+
+### 📘 NOT NULL Constraint (No Empty Spots!)
+
+This rule makes sure a column always has a value—it can’t be empty (NULL). It’s perfect for things like names or IDs that you always need.
+
+**How It Works**: If you mark a column as NOT NULL, you must fill it in when adding a new row. If you don’t, SQL will say, “Oops, you forgot something!”
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with NOT NULL"
+CREATE TABLE students (
+ id INT,
+ name VARCHAR(50) NOT NULL, -- Name must have a value
+ age INT
+);
+INSERT INTO students (id, name, age) VALUES (1, 'Alice', 20); -- This works!
+-- This will fail: INSERT INTO students (id, age) VALUES (2, 21); -- No name!
+```
+
+
+
+| id | name | age |
+|----|-------|-----|
+| 1 | Alice | 20 |
+
+
+:::
+
+> **What NOT to Do**: Don’t skip NOT NULL on important columns like names or IDs—leaving them blank can mess up your records and make it hard to find data later!
+
+### 🔄 UNIQUE Constraint (No Doubles Allowed!)
+
+This rule ensures that every value in a column is different—no duplicates. It’s great for things like email addresses or student IDs.
+
+**How It Works**: If you try to add the same value twice (e.g., two students with the same email), SQL will stop you and say, “Hey, that’s already taken!”
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with UNIQUE"
+CREATE TABLE students (
+ id INT,
+ email VARCHAR(50) UNIQUE -- No two students can have the same email
+);
+INSERT INTO students (id, email) VALUES (1, 'alice@example.com'); -- Works!
+-- This will fail: INSERT INTO students (id, email) VALUES (2, 'alice@example.com'); -- Duplicate!
+```
+
+
+
+| id | email |
+|----|--------------------|
+| 1 | alice@example.com |
+
+
+:::
+
+> **What NOT to Do**: Avoid using UNIQUE on columns that might repeat naturally, like ages (e.g., two 20-year-olds)—it’ll block valid data and cause errors!
+
+### 📘 CHECK Constraint (Set Your Own Rules!)
+
+This lets you create a custom rule for a column, like saying “age must be 18 or older.” It’s like setting a limit on what’s allowed.
+
+**How It Works**: You write a condition, and SQL checks it every time you add or change data. If the data doesn’t match, it won’t let you save it.
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with CHECK"
+CREATE TABLE students (
+ id INT,
+ age INT CHECK (age >= 18) -- Only ages 18 or higher are allowed
+);
+INSERT INTO students (id, age) VALUES (1, 20); -- Works!
+-- This will fail: INSERT INTO students (id, age) VALUES (2, 16); -- Too young!
+```
+
+
+
+| id | age |
+|----|-----|
+| 1 | 20 |
+
+
+:::
+
+> **What NOT to Do**: Don’t make the CHECK rule too strict (e.g., age > 100)—you might block real data and frustrate yourself!
+
+### 🔄 DEFAULT Constraint (Auto-Fill Magic!)
+
+This sets a default value for a column if you don’t provide one. It’s handy for things like setting a default city.
+
+**How It Works**: If you leave a column blank, SQL fills it with the default value you chose, saving you time.
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with DEFAULT"
+CREATE TABLE students (
+ id INT,
+ city VARCHAR(50) DEFAULT 'Unknown' -- If no city is given, it’s 'Unknown'
+);
+INSERT INTO students (id) VALUES (1); -- No city provided, uses default
+INSERT INTO students (id, city) VALUES (2, 'Delhi'); -- Overrides default
+```
+
+
+
+| id | city |
+|----|---------|
+| 1 | Unknown |
+| 2 | Delhi |
+
+
+:::
+
+> **What NOT to Do**: Avoid setting a silly default (e.g., age = 0)—it could lead to confusing or wrong data later!
+
+## ✅ What You’ve Learned
+
+Wow, you’re doing great! You’ve learned:
+- **NOT NULL**: Keeps columns from being empty.
+- **UNIQUE**: Stops duplicates.
+- **CHECK**: Sets custom limits.
+- **DEFAULT**: Adds automatic values.
+
+Try adding these constraints to your own tables and play around with them. Watch out for the "What NOT to Do" tips to keep your database happy and error-free!
+
+---
\ No newline at end of file
diff --git a/docs/sql/SQL-basics/primary-key-foreign-key.md b/docs/sql/SQL-basics/primary-key-foreign-key.md
new file mode 100644
index 00000000..6bda76ca
--- /dev/null
+++ b/docs/sql/SQL-basics/primary-key-foreign-key.md
@@ -0,0 +1,303 @@
+---
+id: primary-key-foreign-key
+title: SQL Primary and Foreign Keys
+sidebar_label: SQL Keys
+sidebar_position: 7
+tags: [sql, primary-key, foreign-key, database, relational-databases]
+description: In this super beginner-friendly guide, you’ll learn about SQL primary keys and foreign keys—unique IDs and table connectors that keep your data organized!
+keywords: [sql, primary key, foreign key, sql tutorial, sql basics, database management, relational databases, sql keys tutorial, sql for beginners, sql in 2025]
+---
+
+## 📙 Welcome to SQL Keys!
+
+Hi, new SQL adventurer! Keys are like superpowers for your database—they help you identify and connect data easily. A **primary key** is like a unique badge for each row, while a **foreign key** is like a bridge linking tables together. We’ll use a `Student Details` table and a `Student Marks` table to explore these with fun examples.
+
+### 📘 What Are Keys?
+
+Keys are special columns that make your database work smoothly:
+- **Primary Key (PK)**: A unique ID for every row in a table (e.g., a student’s roll number).
+- **Foreign Key (FK)**: A column that links to a primary key in another table (e.g., connecting a student to their marks).
+
+Together, they help you find data fast and keep everything connected!
+
+> **Pro Tip**: Always use keys to give your tables structure — think of them as the backbone of your database!
+
+---
+
+## 📘 Primary Key: Your Unique ID!
+
+### What Is a Primary Key?
+
+A primary key is like a special label that makes every row in your table stand out. It’s a column (or a group of columns) that:
+- Gives each row a unique identity.
+- Can’t be empty (NULL).
+- Has no duplicates.
+- Helps you quickly find or link rows.
+
+It’s perfect for things like student IDs or product codes.
+
+### Creating a Primary Key (Single Column)
+
+You set a primary key when you create a table, often on an `id` column.
+
+**How It Works**: Every time you add a row, the PK must be unique, and you can’t skip it.
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with Primary Key"
+CREATE TABLE Student_Details (
+ ID INT PRIMARY KEY, -- Unique ID for each student
+ Name VARCHAR(50),
+ Course VARCHAR(50)
+);
+INSERT INTO Student_Details (ID, Name, Course) VALUES (3032, 'Tom', 'Java'); -- Works!
+-- This will fail: INSERT INTO Student_Details (ID, Name, Course) VALUES (3032, 'Tom', 'Java'); -- Duplicate ID!
+```
+
+
+
+| ID | Name | Course |
+|------|------|--------|
+| 3032 | Tom | Java |
+
+
+:::
+
+### Creating a Composite Primary Key (Multiple Columns)
+
+If one column isn’t unique enough, combine columns to make a composite PK, like a student ID and course ID.
+
+**How It Works**: The combination of columns must be unique—e.g., a student can’t take the same course twice.
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with Composite Primary Key"
+CREATE TABLE Student_Marks (
+ ID INT,
+ Marks INT,
+ PRIMARY KEY (ID, Marks) -- Unique combo
+);
+INSERT INTO Student_Marks (ID, Marks) VALUES (3032, 65); -- Works!
+-- This will fail: INSERT INTO Student_Marks (ID, Marks) VALUES (3032, 65); -- Same combo!
+```
+
+
+
+| ID | Marks |
+|------|-------|
+| 3032 | 65 |
+
+
+:::
+
+### Auto-Incrementing Primary Keys (Hands-Free IDs)
+
+Let SQL generate IDs automatically with AUTO_INCREMENT—great for saving time!
+
+**How It Works**: Each new row gets the next number (e.g., 1, 2, 3…).
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Table with Auto-Increment"
+CREATE TABLE Student_Details (
+ ID INT PRIMARY KEY AUTO_INCREMENT,
+ Name VARCHAR(50),
+ Course VARCHAR(50)
+);
+INSERT INTO Student_Details (Name, Course) VALUES ('Tom', 'Java'); -- id becomes 1
+INSERT INTO Student_Details (Name, Course) VALUES ('John', 'C++'); -- id becomes 2
+```
+
+
+
+| ID | Name | Course |
+|----|------|--------|
+| 1 | Tom | Java |
+| 2 | John | C++ |
+
+
+:::
+
+> **What NOT to Do**:
+- Don’t use changeable data like names as PKs—they might repeat or change over time.
+- Avoid manually setting IDs with AUTO_INCREMENT—it can cause conflicts!
+
+### 📙 Conclusion for Primary Key
+
+You’ve learned how a primary key gives every row its own special ID! The image below shows this in action. It displays a `Student Details` table with `ID` as the primary key, containing `ID: 3032, Name: Tom, Course: Java`, `ID: 8231, Name: John, Course: C++`, `ID: 4506, Name: Alice, Course: Python`, and `ID: 9233, Name: Bob, Course: Oracle`. This ensures every student has a unique identifier, just like a roll number in a class!
+
+
+---
+
+## 📘 Foreign Key: Connecting the Dots!
+
+### What Is a Foreign Key?
+
+A foreign key is like a friendship bracelet that links two tables. It’s a column in one table that points to a primary key in another table. It:
+- Creates relationships (e.g., a student to their marks).
+- Can have duplicates or be empty (NULL) unless you set rules.
+- Stops you from adding invalid links (e.g., a student ID that doesn’t exist).
+
+### Creating a Foreign Key
+
+You add a foreign key when creating a table, and it must match a primary key in another table.
+
+**How It Works**: The FK (e.g., `ID` in `Student Marks`) must match a value in the PK (e.g., `ID` in `Student Details`). If not, SQL says, “No way!”
+
+**Example**:
+ :::info
+
+
+```sql title="Creating Tables with Foreign Key"
+CREATE TABLE Student_Details (
+ ID INT PRIMARY KEY, -- Primary key
+ Name VARCHAR(50),
+ Course VARCHAR(50)
+);
+CREATE TABLE Student_Marks (
+ ID INT,
+ Marks INT,
+ FOREIGN KEY (ID) REFERENCES Student_Details(ID) -- Links to Student_Details.ID
+);
+INSERT INTO Student_Details (ID, Name, Course) VALUES (3032, 'Tom', 'Java'); -- Add student
+INSERT INTO Student_Marks (ID, Marks) VALUES (3032, 65); -- Link to Tom
+-- This will fail: INSERT INTO Student_Marks (ID, Marks) VALUES (999, 50); -- No student 999!
+```
+
+
+
+Student Details Table:
+| ID | Name | Course |
+|------|------|--------|
+| 3032 | Tom | Java |
+
+Student Marks Table:
+| ID | Marks |
+|------|-------|
+| 3032 | 65 |
+
+
+:::
+
+### Cascading Actions with Foreign Keys (Smart Changes!)
+
+You can tell SQL what to do when the primary key data changes:
+- **ON DELETE CASCADE**: If you delete a student, their marks vanish too.
+- **ON UPDATE CASCADE**: If a student’s ID changes, their marks update automatically.
+
+**How It Works**: This keeps related data in sync without extra work.
+
+**Example**:
+ :::info
+
+
+```sql title="Foreign Key with CASCADE"
+CREATE TABLE Student_Marks (
+ ID INT,
+ Marks INT,
+ FOREIGN KEY (ID) REFERENCES Student_Details(ID) ON DELETE CASCADE
+);
+INSERT INTO Student_Details (ID, Name, Course) VALUES (3032, 'Tom', 'Java');
+INSERT INTO Student_Marks (ID, Marks) VALUES (3032, 65);
+DELETE FROM Student_Details WHERE ID = 3032; -- Deletes Tom and his marks!
+```
+
+
+
+Before Delete:
+Student Details Table:
+| ID | Name | Course |
+|------|------|--------|
+| 3032 | Tom | Java |
+
+Student Marks Table:
+| ID | Marks |
+|------|-------|
+| 3032 | 65 |
+
+After Delete: (Both tables empty)
+
+
+:::
+
+> **What NOT to Do**:
+- Don’t create the FK table before the PK table—SQL needs the PK first!
+- Avoid CASCADE if you want to keep related data after deletions!
+
+### 📙 Conclusion for Foreign Key
+
+Awesome job! You’ve learned how a foreign key connects tables like magic. The image below shows this in action. It displays the `Student Details` table with `ID` as the primary key (`ID: 3032, Name: Tom, Course: Java`, etc.) and the `Student Marks` table with `ID` as the foreign key (`ID: 3032, Marks: 65`, etc.), linking students to their marks. This keeps everything connected perfectly!
+
+
+
+---
+
+## 🧩 Comparison: Primary Key vs. Foreign Key
+
+Let’s compare these two keys side by side to see how they’re different and work together!
+
+| **Feature** | **Primary Key (PK)** | **Foreign Key (FK)** |
+|-------------------------|--------------------------------------------|--------------------------------------------|
+| **Purpose** | Uniquely identifies each row in one table. | Links to a PK in another table. |
+| **Uniqueness** | Must be unique and not NULL. | Can have duplicates or NULL (unless restricted). |
+| **Location** | One per table, in that table. | In a different table, pointing to a PK. |
+| **Example** | `ID` in `Student_Details` table. | `ID` in `Student_Marks` table. |
+| **Changes** | Can’t change easily—used as a base. | Can update or delete with CASCADE rules. |
+| **Use Case** | Identifying a student (e.g., roll number).| Connecting a student to their marks. |
+
+**Simple Explanation**:
+- A PK is like your personal ID number—it’s yours alone in your table.
+- An FK is like a reference to someone else’s ID—it connects your table to theirs.
+- Together, they build a network where every piece of data fits perfectly!
+
+**Example of Both Together**:
+ :::info
+
+
+```sql title="Using PK and FK Together"
+CREATE TABLE Student_Details (
+ ID INT PRIMARY KEY,
+ Name VARCHAR(50),
+ Course VARCHAR(50)
+);
+CREATE TABLE Student_Marks (
+ ID INT,
+ Marks INT,
+ FOREIGN KEY (ID) REFERENCES Student_Details(ID)
+);
+INSERT INTO Student_Details (ID, Name, Course) VALUES (3032, 'Tom', 'Java');
+INSERT INTO Student_Marks (ID, Marks) VALUES (3032, 65);
+```
+
+
+
+Student Details Table:
+| ID | Name | Course |
+|------|------|--------|
+| 3032 | Tom | Java |
+
+Student Marks Table:
+| ID | Marks |
+|------|-------|
+| 3032 | 65 |
+
+
+:::
+
+> **What NOT to Do**: Don’t mix up PK and FK roles—use PK for unique IDs and FK for linking only!
+
+## ✅ What You’ve Learned
+
+You’re a SQL star! You’ve mastered:
+- **Primary Key**: Your table’s unique identifier.
+- **Foreign Key**: The link between tables.
+- **Comparison**: How they differ and work together.
+- **Cascading**: Smart updates and deletes.
+
+Try creating tables with both PK and FK, and test CASCADE. Avoid the "What NOT to Do" tips to keep your database strong and connected!
\ No newline at end of file