1. Three-Schema Architecture of DBMS
1. Three-Schema Architecture

The Three-Schema Architecture divides a database system into three different levels:

1. External Level

2. Conceptual Level

3. Internal Level

The main purpose is to separate what users see from how data is logically organized and how it is physically stored.

Easy Memory Trick
Remember:

> External → Conceptual → Internal
User → Database Design → Storage
2. Neat Diagram
USERS / APPLICATIONS │ ┌──────────────┴──────────────┐ │ │ External View 1 External View 2 (User View) (User View) │ │ └──────────────┬──────────────┘ │ External / Conceptual Mapping │ ▼ ┌─────────────────────┐ │ CONCEPTUAL LEVEL │ │ (Logical View) │ │ │ │ Tables, attributes, │ │ relationships etc. │ └──────────┬──────────┘ │ Conceptual / Internal Mapping │ ▼ ┌─────────────────────┐ │ INTERNAL LEVEL │ │ (Physical View) │ │ │ │ Files, blocks, │ │ indexes, storage │ └──────────┬─────────┘ │ ▼ PHYSICAL STORAGE Disk / SSD / etc.
One-line memory:

> External = What user sees
Conceptual = What database contains
Internal = How database stores it
3. External Level

The External Level is the highest level of the database.

It describes the database from the user's point of view.

Different users can see different views of the same database.

Example:

Consider a college database.

A student may see:

Student Name

Register Number

Marks

Attendance

A teacher may see:

Student Name

Register Number

Marks

Attendance

Internal Marks

Assignment Marks

The administrator may see:

Student Details

Fee Details

Attendance

Marks

Course Details

Staff Details

All these users are accessing the same database, but they see different information.

Important points

Also called View Level.

It is closest to the user.

Shows only required information.

Hides unnecessary information.

Multiple external views can exist.

Easy memory:

> External = Eye of the user
4. Conceptual Level

The Conceptual Level is the middle level.

It describes the complete logical structure of the database.

It tells us:

What tables exist

What attributes exist

What relationships exist

What constraints exist

Example:

A college database may have:

STUDENT ---------------- Student_ID Name Department Email COURSE ---------------- Course_ID Course_Name MARKS ---------------- Student_ID Course_ID Marks

The conceptual level describes how these tables are related.

For example:

STUDENT ───────< MARKS >────── COURSE
Important points

Also called Logical Level.

Describes the complete database logically.

Hides physical storage details.

Defines tables, relationships and constraints.

Usually designed by the database administrator/database designer.

Easy memory:

> Conceptual = Complete database map
5. Internal Level

The Internal Level is the lowest level.

It explains how the data is actually stored inside the computer.

It deals with:

Files

Disk blocks

Storage locations

Indexes

Data structures

Record placement

Access methods

For example, the database may store student records in:

Disk ↓ Data Blocks ↓ Records ↓ Indexes

Users don't need to know these details.

Important points

Also called Physical Level.

Closest to physical storage.

Describes how data is stored.

Deals with storage efficiency and access speed.

Hidden from normal users.

Easy memory:

> Internal = Inside the storage
6. Mapping Between the Levels

The levels need to communicate with each other.

This is done using mappings.

There are mainly two mappings:

1. External–Conceptual Mapping

Connects the external views with the conceptual database.

External Level ↓ External–Conceptual Mapping ↓ Conceptual Level

It determines how a user's view corresponds to the logical database.

2. Conceptual–Internal Mapping

Connects the conceptual level with the internal storage.

Conceptual Level ↓ Conceptual–Internal Mapping ↓ Internal Level

It determines how logical data is stored physically.

Easy memory:

> External ↔ Conceptual ↔ Internal
7. Data Independence

One of the most important advantages of three-schema architecture is Data Independence.

It means:

> Changes at one level should not greatly affect the other levels.

There are two types.

A. Physical Data Independence

It means we can change the physical storage without changing the logical database.

Example:

Suppose student data is stored using:

Old: Sequential files

We change it to:

New: Indexed files

The tables and applications can continue working normally.

Memory:

> Physical changes → Logical structure remains same
B. Logical Data Independence

It means we can change the logical structure without changing users' views.

Example:

Suppose we add:

Phone_Number

to the STUDENT table.

Existing users who don't need the phone number can continue using their existing views.

Memory:

> Logical changes → User views remain same
8. Advantages of Three-Schema Architecture
1. Data Independence

Changes in storage or logical structure have less effect on users.

2. Security

Users can be given only the information they need.

Example:

Student → Marks

Accountant → Fees

Teacher → Attendance

3. Multiple Views

Different users can have different views of the same database.

4. Easier Database Management

Database administrators can manage storage separately from user views.

5. Data Abstraction

Unnecessary implementation details are hidden.

6. Easier Maintenance

Changes can be made at one level without completely changing the entire system.

Easy memory:

> S-M-M-A-M-M

You can remember the important advantages as:

Security + Multiple views + Maintenance + Abstraction + Independence + Management
9. Limitations of Three-Schema Architecture
1. Complexity

Managing three levels and mappings can be complicated.

2. Implementation Cost

Designing and maintaining mappings requires additional effort.

3. Performance Overhead

Mappings between levels may introduce some processing overhead.

4. Difficult to Design

Proper separation between physical, logical and external levels requires skilled database designers.

5. Not Completely Independent

Although data independence is provided, some changes may still require modifications at other levels.

⭐ Quick Revision – Three-Schema Architecture
Level Simple Meaning Memory
External What user sees 👁️ User View
Conceptual Logical structure 🧠 Database Map
Internal How data is stored 💾 Storage
Remember:

> USER → LOGIC → STORAGE
External → Conceptual → Internal
2. DBMS – Features, Advantages over File System & Applications
1. DBMS

DBMS stands for Database Management System.

It is software used to:

Create databases

Store data

Organize data

Retrieve data

Update data

Delete data

Protect data

Examples:

MySQL

Oracle Database

PostgreSQL

Microsoft SQL Server

SQLite

Simple example

Instead of storing college student information in many separate files:

students.xlsx marks.xlsx fees.xlsx attendance.xlsx

a DBMS can manage them as a connected database.

2. Basic Working of DBMS
USER │ ▼ SQL / Application │ ▼ DBMS │ ┌────┼────┐ ▼ ▼ ▼ Store Search Update │ │ │ └────┼────┘ ▼ DATABASE
Simple flow:

> User → DBMS → Database → Result
3. Features of DBMS
1. Data Storage

DBMS stores large amounts of data in an organized manner.

Example:
Student ID | Name | Marks
2. Data Retrieval

Users can quickly find required information.

Example:
SELECT * FROM Student WHERE Marks > 80;

This retrieves students who scored above 80.

3. Data Manipulation

DBMS allows users to:

Insert

Update

Delete

data.

Example:

Add student

Change marks

Delete student

4. Data Security

DBMS protects data from unauthorized users.

Example:

Student → Can view marks

Teacher → Can update marks

Admin → Can manage everything

5. Data Integrity

DBMS ensures that stored data is accurate and valid.

Example:

A student's mark cannot normally be:

Marks = 150

if the allowed range is 0–100.

6. Reduced Data Redundancy

Redundancy means unnecessary duplication of data.

Without DBMS:

Student name repeated in many different files.

DBMS reduces this unnecessary duplication.

Memory:

> DBMS = Less duplicate data
7. Data Sharing

Multiple users can access the database at the same time.

Teacher ─┐ Student ─┼──→ Database Admin ───┘
8. Backup and Recovery

DBMS can recover data after:

System failure

Power failure

Hardware failure

Software failure

9. Concurrency Control

Multiple users can work with the database simultaneously while maintaining data consistency.

Example:

Two bank employees may access customer accounts at the same time.

10. Transaction Management

DBMS ensures that database operations are completed properly.

For example, in a bank transfer:

Account A → ₹1000 Account B ← ₹1000

Both operations should happen correctly.

4. Advantages of DBMS over File System

This is a very important exam comparison.

DBMS File System
Reduces data redundancy More duplicate data
Better data security Less security
Supports data sharing Limited sharing
Provides backup and recovery Recovery is difficult
Maintains data consistency Inconsistency can occur
Supports concurrent users Limited concurrency
Provides data independence Low data independence
Provides integrity constraints Difficult to enforce
Easy data retrieval using SQL Searching can be difficult
Centralized data management Data scattered across files
5. Explain Each Advantage
1. Reduced Data Redundancy

In a file system, the same data may be stored in many files.

Example:
Student Name ↓ Marks File Fees File Attendance File

The same student information may be repeated.

DBMS reduces unnecessary duplication.

2. Better Data Security

DBMS allows access permissions.

Example:

Student → View marks

Teacher → Enter marks

Admin → Full access

This is harder to manage in a normal file system.

3. Data Consistency

If the same data exists in multiple files, one file may be updated while another is not.

This causes inconsistency.

DBMS helps maintain a consistent version of data.

4. Easy Data Sharing

Many users can access the same database.

Student ↓ Teacher → College Database ← Admin ↑ Parent
5. Backup and Recovery

DBMS provides mechanisms for recovering data after system failures.

> Computer crashes → Database can be restored from backup/recovery mechanisms.
6. Data Integrity

DBMS can enforce rules.

Example:

Age > 0

Marks between 0 and 100

Student ID must be unique

This helps prevent invalid data.

7. Concurrent Access

Multiple users can access the same database simultaneously.

Employee 1 ─┐ Employee 2 ─┼──→ Bank Database Employee 3 ─┘

DBMS manages these simultaneous operations.

8. Easy Data Retrieval

Using SQL, required data can be searched easily.

SELECT Name FROM Student WHERE Marks > 90;

The DBMS quickly returns the required records.

6. Real-World Applications of DBMS

DBMS is used almost everywhere large amounts of organized data are needed.

1. Banking

Banks use DBMS to store:

Customer details

Account information

Transactions

Loans

Balance

Example:

When you withdraw ₹5,000:

Account Balance ↓ DBMS ↓ Balance updated
2. Railway Reservation

Railway systems use DBMS to manage:

Passenger information

Train details

Seat availability

Ticket booking

Cancellation

Example:
Search Train ↓ Check Seat ↓ Book Ticket ↓ Update Database
3. Hospitals

Hospital DBMS stores:

Patient details

Doctor details

Medical records

Appointments

Billing

Medicine information

Example:

A doctor can retrieve a patient's previous records from the database.

4. Educational Institutions

Colleges and universities use DBMS for:

Student records

Marks

Attendance

Fees

Courses

Examination results

Example:
Student ID ↓ Marks + Attendance + Fees
5. E-Commerce

Websites such as online shopping platforms use databases to manage:

Products

Customers

Orders

Payments

Delivery details

Example:
Customer ↓ Product ↓ Order ↓ Payment ↓ Delivery
6. Social Media

Social media applications use DBMS to manage:

User accounts

Posts

Comments

Likes

Followers

Messages

7. Airlines

Airlines use DBMS for:

Flight schedules

Passenger details

Seat reservations

Ticketing

Airport information

8. Telecommunications

Telecom companies use DBMS for:

Customer information

Call records

Recharge information

Billing

Data usage

.

3. Draw the DBMS Architecture and Explain All Its Components
1. DBMS Architecture

DBMS architecture explains how users interact with the database through the DBMS and how different components work together.

A simple way to remember the architecture is:

> User → Interface → DBMS → Database
Neat Diagram
USERS │ ┌─────────────┼─────────────┐ │ │ │ Student Staff Admin │ │ │ └─────────────┼─────────────┘ ▼ ┌─────────────────┐ │ User Interface │ │ / Applications │ └────────┬────────┘ │ ▼ ┌────────────────────────┐ │ DBMS │ │ │ │ ┌────────────────────┐ │ │ │ Query Processor │ │ │ └─────────┬──────────┘ │ │ │ │ │ ┌─────────▼──────────┐ │ │ │ Storage Manager │ │ │ └─────────┬──────────┘ │ └───────────┼────────────┘ │ ┌────────────┼────────────┐ ▼ ▼ ▼ Database Indexes Metadata │ ▼ Physical Storage Disk / SSD
2. Main Components of DBMS

The important components are:

1. Users

2. User Interface / Application Programs

3. Query Processor

4. Storage Manager

5. Database

6. Metadata / Data Dictionary

3. Users

Users are the people or applications that interact with the database.

Types of users
1. End Users

They directly use applications.

Example:
> Student checking examination marks.
2. Application Programmers

They create programs that communicate with the database.

Example:
> Developer creating a college management application.
3. Database Administrator (DBA)

The DBA manages the entire database.

The DBA handles:

Security

User permissions

Backup

Recovery

Database maintenance

Performance

Easy memory:

> User = Person who uses the database
4. User Interface / Application Programs

Users normally don't directly access the database storage.

They use an application or interface.

Examples:

College App

Banking App

Railway Booking App

Online Shopping Website

The application sends requests to the DBMS.

Example:

A student clicks:

> "View My Marks"

The application sends a query to the DBMS.

Student ↓ College App ↓ DBMS ↓ Database ↓ Marks
5. Query Processor

The Query Processor is one of the most important components of DBMS.

Its job is to understand and execute SQL queries.

For example:
SELECT Name, Marks FROM Student WHERE Marks > 80;

The query processor processes this command and finds the required records.

Main functions

Understand SQL commands

Check SQL syntax

Convert queries into an executable form

Find an efficient way to execute queries

Execute the query

Main parts of Query Processor
1. DDL Interpreter

Processes DDL commands such as:

CREATE

ALTER

DROP

2. DML Compiler

Processes DML commands such as:

SELECT

INSERT

UPDATE

DELETE

3. Query Optimizer

Finds an efficient way to execute a query.

For example:

If there are several ways to search a table, the optimizer selects a faster method.

4. Query Evaluation Engine

Actually executes the query and produces the result.

Easy memory:

> Query Processor = Understand → Optimize → Execute
6. Storage Manager

The Storage Manager manages the data stored on physical storage.

It acts as a bridge between the database and physical storage.

DBMS ↓ Storage Manager ↓ Disk / SSD
Main functions

Store data

Retrieve data

Update data

Manage files

Manage memory

Maintain security

Maintain consistency

7. Main Parts of Storage Manager
1. File Manager

Manages how database files are stored on disk.

It handles:

Data files

File organization

Storage space

2. Buffer Manager

Manages data between main memory and disk.

Disk ↓ Buffer Manager ↓ RAM

It loads required data into memory when needed.

Why important?

Accessing RAM is generally much faster than accessing disk storage, so proper buffer management improves performance.

3. Transaction Manager

Manages database transactions.

Example:

Suppose ₹1,000 is transferred:

Account A: -₹1,000 Account B: +₹1,000

The transaction manager ensures the operation is handled correctly.

4. Authorization and Integrity Manager

It checks:

Who is allowed to access data

Whether data follows database rules

Example:

Student → View marks

Teacher → Update marks

Admin → Full access

8. Database

The database contains the actual stored data.

For example, a college database may contain:

STUDENT

COURSE

MARKS

ATTENDANCE

FEES

STAFF

The data is stored in tables and other database structures.

9. Metadata / Data Dictionary

Metadata means "data about data."

It stores information about the database structure.

For example:
Table Name: STUDENT Column 1: Student_ID Column 2: Name Column 3: Department Column 4: Marks

It can also contain information about:

Tables

Columns

Data types

Constraints

Users

Permissions

Indexes

Easy memory:

> Database = Actual data
Metadata = Information about the data
10. Simple Working of DBMS Architecture

Suppose a student wants to see marks.

Student ↓ Application ↓ SQL Query ↓ Query Processor ↓ Storage Manager ↓ Database ↓ Result ↓ Application ↓ Student
Easy memory:

> Ask → Process → Find → Show
⭐ Quick Revision of DBMS Architecture
Component Main Job
UsersUse database
ApplicationProvides interface
Query ProcessorProcesses SQL
Storage ManagerManages stored data
File ManagerManages files
Buffer ManagerManages memory
Transaction ManagerManages transactions
Authorization ManagerControls access
DatabaseStores actual data
MetadataStores database structure information
4. Discuss DCL and TCL Commands with Examples

DCL and TCL are two important groups of SQL commands.

Remember:

> DCL = Control Access
TCL = Control Transactions
A. DCL – Data Control Language

DCL stands for Data Control Language.

DCL is used to control access and permissions in a database.

The two important DCL commands are:

1. GRANT

2. REVOKE

Easy memory:

> GRANT = Give permission
REVOKE = Take permission back
1. GRANT Command

The GRANT command gives permissions to a user.

Syntax
GRANT privilege ON object TO user;
Example
GRANT SELECT ON Student TO user1;

This gives user1 permission to view the Student table.

Giving multiple permissions
GRANT SELECT, INSERT, UPDATE ON Student TO user1;

Now the user can:

View data

Insert data

Update data

Common privileges
Privilege Meaning
SELECTRead data
INSERTAdd data
UPDATEModify data
DELETEDelete data
ALLAll available privileges
2. REVOKE Command

The REVOKE command removes previously granted permissions.

Syntax
REVOKE privilege ON object FROM user;
Example
REVOKE UPDATE ON Student FROM user1;

Now user1 cannot update the Student table.

Another example

First:

GRANT SELECT, INSERT ON Student TO user1;

Later:

REVOKE INSERT ON Student FROM user1;

Now:

SELECT → Allowed

INSERT → Not allowed

B. TCL – Transaction Control Language

TCL stands for Transaction Control Language.

TCL is used to manage transactions in a database.

A transaction is a group of database operations treated as one unit.

Example:
Bank Transfer Debit ₹1000 from A + Credit ₹1000 to B = One Transaction

Important TCL commands are:

1. COMMIT

2. ROLLBACK

3. SAVEPOINT

Easy memory:

> COMMIT = Save
ROLLBACK = Undo
SAVEPOINT = Mark a point
1. COMMIT

COMMIT permanently saves the changes made during the transaction.

Example
INSERT INTO Student VALUES (101, 'Arun', 85); COMMIT;

After COMMIT, the inserted data is saved.

Memory:

> COMMIT = Confirm
2. ROLLBACK

ROLLBACK cancels changes that have not been committed.

Example
UPDATE Student SET Marks = 50 WHERE Student_ID = 101; ROLLBACK;

The update is cancelled and the previous value is restored, subject to the DBMS's transaction behavior.

Memory:

> ROLLBACK = Go back
3. SAVEPOINT

SAVEPOINT creates a temporary point inside a transaction.

This allows you to roll back to that particular point.

Example
UPDATE Student SET Marks = 80 WHERE Student_ID = 101; SAVEPOINT S1; UPDATE Student SET Marks = 90 WHERE Student_ID = 102; ROLLBACK TO S1;

The second update can be undone while keeping the earlier work.

Memory:

> SAVEPOINT = Checkpoint
DCL vs TCL
DCL TCL
Data Control Language Transaction Control Language
Controls access Controls transactions
Mainly manages permissions Manages changes
GRANT COMMIT
REVOKE ROLLBACK
Related to security Related to transaction management
⭐ Super Memory Trick

> DCL → Who can access?
TCL → What changes should be saved/undone?
5. DDL and DML Commands with Syntax and Examples

SQL commands are divided into different categories.

For this question, focus on:

DDL
> Data Definition Language

DML
> Data Manipulation Language
The easiest way to remember them:

> DDL = Design the table
DML = Deal with the data
A. DDL – Data Definition Language

DDL is used to create and modify the structure of database objects.

Common DDL commands:

1. CREATE

2. ALTER

3. DROP

4. TRUNCATE

5. RENAME

1. CREATE

Used to create a new database object such as a table.

Syntax
CREATE TABLE table_name ( column1 datatype, column2 datatype, ... );
Example
CREATE TABLE Student ( Student_ID INT, Name VARCHAR(50), Marks INT );

This creates a table called Student.

Structure:
Student --------------------- Student_ID Name Marks
Memory:

> CREATE = Make something new
2. ALTER

Used to modify the structure of an existing table.

For example, adding a column.

Syntax
ALTER TABLE table_name ADD column_name datatype;
Example
ALTER TABLE Student ADD Email VARCHAR(100);

Now the table contains:

Student_ID

Name

Marks

Email

Memory:

> ALTER = Change structure
Adding another column
ALTER TABLE Student ADD Phone VARCHAR(15);
3. DROP

Used to completely remove a database object.

Syntax
DROP TABLE table_name;
Example
DROP TABLE Student;

The table and its data are removed.

Memory:

> DROP = Destroy the object
⚠️ Important:

DROP removes the table structure and its data.
4. TRUNCATE

Used to remove all records from a table while keeping the table structure.

Syntax
TRUNCATE TABLE table_name;
Example
TRUNCATE TABLE Student;

After this:

Student table → Still exists

Student records → Removed

Memory:

> TRUNCATE = Empty the table
5. RENAME

Used to change the name of a database object.

Example
RENAME TABLE Student TO Students;

The table name changes from:

Student

to:

Students

Note: Exact RENAME syntax can vary between database systems.

Memory:

> RENAME = Change the name
⭐ DDL Quick Memory
> C-A-D-T-R

C – CREATE
A – ALTER
D – DROP
T – TRUNCATE
R – RENAME

Think:

> Create → Alter → Drop → Truncate → Rename
B. DML – Data Manipulation Language

DML is used to work with the data stored inside tables.

The common DML commands are:

1. INSERT

2. UPDATE

3. DELETE

SELECT is often taught separately as DQL (Data Query Language), though some textbooks include it under DML. Follow your syllabus convention.
1. INSERT

Used to add new records into a table.

Syntax
INSERT INTO table_name VALUES (value1, value2, ...);
Example
INSERT INTO Student VALUES (101, 'Arun', 85);

The record is added:

101 | Arun | 85
Memory:

> INSERT = Add
2. UPDATE

Used to modify existing records.

Syntax
UPDATE table_name SET column_name = value WHERE condition;
Example
UPDATE Student SET Marks = 90 WHERE Student_ID = 101;

The student's marks change:

85 → 90
Memory:

> UPDATE = Change
⚠️ Important exam point: Use a WHERE condition when you intend to update specific rows. Without WHERE, many DBMSs will update all rows.
3. DELETE

Used to remove records from a table.

Syntax
DELETE FROM table_name WHERE condition;
Example
DELETE FROM Student WHERE Student_ID = 101;

The record of student 101 is deleted.

Memory:

> DELETE = Remove data
⚠️ Without WHERE, a DELETE statement can remove all rows from the table.
4. SELECT – Retrieving Data

Although many syllabi classify SELECT as DQL, it is frequently discussed along with DML.

It is used to retrieve data.

Syntax
SELECT column_name FROM table_name WHERE condition;
Example
SELECT Name, Marks FROM Student WHERE Marks > 80;

This displays students who scored more than 80.

Memory:

> SELECT = See/Search data
DDL vs DML

This comparison is very important for exams.

DDL DML
Data Definition Language Data Manipulation Language
Deals with database structure Deals with data
Creates/modifies objects Inserts/changes/deletes records
CREATE INSERT
ALTER UPDATE
DROP DELETE
TRUNCATE SELECT*
RENAME
Example: Create table Example: Add student

*SELECT is commonly classified as DQL in many textbooks.

🔥 Very Easy Difference

Imagine a college notebook.

DDL = Designing the notebook

Create pages
Change page structure
Remove pages
Rename sections

DML = Writing inside the notebook

Add information
Change information
Delete information
Read information
So:

> DDL → Structure
DML → Data
6. Explain SQL Aggregate Functions with Suitable Syntax and Examples
1. Aggregate Functions

Aggregate functions are SQL functions that perform a calculation on multiple rows and return one result.

Easy meaning:

> Many values → One answer
For example:
Marks: 80, 70, 90, 60, 100 ↓ AVG() ↓ 80

The five marks become one answer: 80.

2. Main SQL Aggregate Functions

The five important aggregate functions are:

1. COUNT() → Counts values

2. SUM() → Adds values

3. AVG() → Finds average

4. MAX() → Finds highest value

5. MIN() → Finds lowest value

⭐ Easy Memory

> C-S-A-M-M

Count
Sum
Average
Maximum
Minimum

Or remember:

> COUNT = How many?
SUM = How much total?
AVG = What is the average?
MAX = What is highest?
MIN = What is lowest?
3. Sample Table

Consider the following Student table:

Student_ID Name Department Marks
101ArunAI&ML80
102RaviAI&ML70
103PriyaCSE90
104KumarCSE60
105AnuAI&ML100

We will use this table for all examples.

4. COUNT()

COUNT() is used to count the number of rows or non-NULL values.

Syntax
SELECT COUNT(column_name) FROM table_name;
Example
SELECT COUNT(Student_ID) FROM Student;

Result

5

There are 5 students.

To count all rows:

SELECT COUNT(*) FROM Student;

Result:

5
Memory:

> COUNT = Count how many
5. SUM()

SUM() calculates the total of a numeric column.

Syntax
SELECT SUM(column_name) FROM table_name;
Example
SELECT SUM(Marks) FROM Student;

Calculation:

80 + 70 + 90 + 60 + 100 = 400

Result:

400
Memory:

> SUM = Total
6. AVG()

AVG() calculates the average value.

Syntax
SELECT AVG(column_name) FROM table_name;
Example
SELECT AVG(Marks) FROM Student;

Calculation:

400 / 5 = 80

Result:

80
Memory:

> AVG = Average
7. MAX()

MAX() returns the largest value.

Syntax
SELECT MAX(column_name) FROM table_name;
Example
SELECT MAX(Marks) FROM Student;

Result:

100
Memory:

> MAX = Highest
8. MIN()

MIN() returns the smallest value.

Syntax
SELECT MIN(column_name) FROM table_name;
Example
SELECT MIN(Marks) FROM Student;

Result:

60
Memory:

> MIN = Lowest
9. Using Multiple Aggregate Functions

We can use multiple functions in a single query.

SELECT COUNT(*) AS Total_Students, SUM(Marks) AS Total_Marks, AVG(Marks) AS Average_Marks, MAX(Marks) AS Highest_Marks, MIN(Marks) AS Lowest_Marks FROM Student;

Result

Total Students Total Marks Average Highest Lowest
5 400 80 100 60

This is a very good example to write in the exam because it demonstrates all five aggregate functions together.

10. Aggregate Functions with WHERE

Aggregate functions can be used with WHERE to calculate values for selected rows.

Example

Find the average marks of AI&ML students:

SELECT AVG(Marks) FROM Student WHERE Department = 'AI&ML';

AI&ML marks:

80, 70, 100

Average:

250 / 3 = 83.33
11. Aggregate Functions with GROUP BY

GROUP BY is used when we want separate aggregate results for different groups.

Example

Find the average marks for each department:

SELECT Department, AVG(Marks) FROM Student GROUP BY Department;

Possible result:

Department Average Marks
AI&ML83.33
CSE75
Easy understanding:

Without GROUP BY:
> Give one overall answer.

With GROUP BY:
> Give one answer for each group.
12. Sample Program
CREATE TABLE Student ( Student_ID INT, Name VARCHAR(50), Department VARCHAR(20), Marks INT ); INSERT INTO Student VALUES (101, 'Arun', 'AI&ML', 80), (102, 'Ravi', 'AI&ML', 70), (103, 'Priya', 'CSE', 90), (104, 'Kumar', 'CSE', 60), (105, 'Anu', 'AI&ML', 100); SELECT COUNT(*) AS Total_Students FROM Student; SELECT SUM(Marks) AS Total_Marks FROM Student; SELECT AVG(Marks) AS Average_Marks FROM Student; SELECT MAX(Marks) AS Highest_Marks FROM Student; SELECT MIN(Marks) AS Lowest_Marks FROM Student;
⭐ Quick Revision

COUNT() → Number
SUM() → Total
AVG() → Average
MAX() → Highest
MIN() → Lowest
7. E-R Diagram for Student Course Registration System

An E-R (Entity-Relationship) Diagram represents:

Entities

Attributes

Relationships

For a Student Course Registration System, the main entities can be:

1. STUDENT

2. COURSE

3. REGISTRATION

1. Identify Entities
Entity 1: STUDENT

Attributes:

Student_ID

Student_Name

Email

Department

Entity 2: COURSE

Attributes:

Course_ID

Course_Name

Credits

Entity 3: REGISTRATION

Attributes:

Registration_ID

Registration_Date

Semester

2. Identify Relationships

A student can register for many courses.

A course can have many students.

Therefore:

> STUDENT ↔ COURSE = Many-to-Many (M:N)

But relational databases cannot directly represent an M:N relationship as a simple pair of tables.

So we create an intermediate entity:

> REGISTRATION
3. E-R Diagram
┌─────────────────────┐ │ STUDENT │ │─────────────────────│ │ PK Student_ID │ │ Student_Name │ │ Email │ │ Department │ └──────────┬──────────┘ │ │ 1 │ │ registers │ │ M ┌──────────▼──────────┐ │ REGISTRATION │ │─────────────────────│ │ PK Registration_ID │ │ Registration_Date │ │ Semester │ │ FK Student_ID │ │ FK Course_ID │ └──────────┬──────────┘ │ │ M │ │ belongs to │ │ 1 ┌──────────▼──────────┐ │ COURSE │ │─────────────────────│ │ PK Course_ID │ │ Course_Name │ │ Credits │ └─────────────────────┘
4. Understanding the Relationship

Suppose:

Student 101 → DBMS Student 101 → Java Student 102 → DBMS

One student can register for many courses.

Similarly:

DBMS → Student 101 DBMS → Student 102 DBMS → Student 103

One course can have many students.

Therefore:

STUDENT 1 ───── M REGISTRATION M ───── 1 COURSE

This represents the original:

STUDENT M ───── N COURSE
5. Convert E-R Diagram into Relational Tables

Now convert each entity into a table.

Step 1: Convert STUDENT Entity

Create a STUDENT table.

STUDENT( Student_ID PRIMARY KEY, Student_Name, Email, Department )

Example:

Student_ID Student_Name Email Department
101Arunarun@email.comAI&ML
102Raviravi@email.comCSE
Step 2: Convert COURSE Entity

Create a COURSE table.

COURSE( Course_ID PRIMARY KEY, Course_Name, Credits )

Example:

Course_ID Course_Name Credits
C101DBMS4
C102Java4
C103AI3
Step 3: Convert REGISTRATION Entity

Create a REGISTRATION table.

REGISTRATION( Registration_ID PRIMARY KEY, Student_ID FOREIGN KEY, Course_ID FOREIGN KEY, Registration_Date, Semester )

Example:

Registration_ID Student_ID Course_ID Date Semester
1101C1012026-08-01III
2101C1022026-08-01III
3102C1012026-08-02III
6. SQL Implementation
CREATE TABLE Student ( Student_ID INT PRIMARY KEY, Student_Name VARCHAR(50), Email VARCHAR(100), Department VARCHAR(50) ); CREATE TABLE Course ( Course_ID VARCHAR(10) PRIMARY KEY, Course_Name VARCHAR(50), Credits INT ); CREATE TABLE Registration ( Registration_ID INT PRIMARY KEY, Student_ID INT, Course_ID VARCHAR(10), Registration_Date DATE, Semester VARCHAR(20), FOREIGN KEY (Student_ID) REFERENCES Student(Student_ID), FOREIGN KEY (Course_ID) REFERENCES Course(Course_ID) );
7. Why Registration Table is Needed

This is an important point to remember for the exam.

Suppose we directly put courses inside Student:

Student 101 → DBMS, Java, AI

This creates problems because one student can have many courses.

Instead: STUDENT ↓ REGISTRATION ↓ COURSE

The registration table converts the M:N relationship into two 1:M relationships.

⭐ Memory

> Many-to-Many → Create a middle table
8. Conversion Steps – Easy Memory

Remember these 5 steps:

Step 1

> Find entities

Step 2

> Find attributes

Step 3

> Find relationships

Step 4

> Identify primary keys

Step 5

> Convert relationships using foreign keys/intermediate tables
Super memory:

> Entity → Attribute → Relationship → Key → Table
8. Concepts of Keys, Attributes and Constraints in E-R Model
A. Attributes

An attribute is a property or characteristic of an entity.

For example:
STUDENT │ ├── Student_ID ├── Name ├── Email └── Department

Here, Student_ID, Name, Email, and Department are attributes.

Easy memory:

> Entity = Thing
Attribute = Information about the thing
Example:
Student = Entity
Name = Attribute
Age = Attribute
Email = Attribute
1. Types of Attributes
1. Simple Attribute

Cannot be divided further.

Age

Gender

Student_ID

2. Composite Attribute

Can be divided into smaller attributes.

Name ↓ First Name Middle Name Last Name

Another example:

Address ↓ Street City State PIN
Memory:

> Simple = Cannot split
Composite = Can split
3. Single-Valued Attribute

Has only one value for an entity.

Student_ID = 101

A student normally has one student ID.

4. Multi-Valued Attribute

Can have multiple values.

Phone_Number ↓ 9876543210 9123456789

A student may have multiple phone numbers.

In an E-R diagram, a multivalued attribute is usually represented using a double oval.

5. Derived Attribute

Its value can be calculated from another attribute.

Date_of_Birth ↓ Age

Age can be calculated from Date of Birth.

> Age = Derived Attribute

Usually represented using a dashed oval in an E-R diagram.

6. Stored Attribute

An attribute whose value is actually stored in the database.

Example:

Date_of_Birth

The age can be calculated from it.

Date_of_Birth → Stored
Age → Derived
B. Keys

A key is an attribute or group of attributes used to identify records uniquely.

Example:
Student_ID

Two students should not have the same Student ID.

Easy memory:

> Key = Identity
1. Super Key

A Super Key is any attribute or combination of attributes that can uniquely identify a record.

Example:

Student_ID

Student_ID + Name

Student_ID + Email

All can identify a student uniquely if Student_ID is unique.

Therefore they are super keys.

2. Candidate Key

A Candidate Key is a minimal super key.

It uniquely identifies a record and contains no unnecessary attribute.

Example:

Student_ID

Email

If both are unique, both can be candidate keys.

Memory:

> Candidate = Possible Primary Key
3. Primary Key

The Primary Key is the candidate key selected to uniquely identify each record.

Example:
Student_ID

Rules:

Must be unique

Cannot normally be NULL

Identifies each record

Example:
Student_ID | Name -----------|------ 101 | Arun 102 | Ravi 103 | Priya
Memory:

> Primary Key = Main identity
4. Alternate Key

Candidate keys that are not selected as the primary key are called alternate keys.

Example:

Candidate keys:

Student_ID

Email

If we select:

Student_ID → Primary Key

Then:

Email → Alternate Key
Memory:

> Alternate = Candidate key not chosen
5. Foreign Key

A Foreign Key is an attribute that refers to the primary key of another table.

Example:
STUDENT Student_ID → Primary Key REGISTRATION Student_ID → Foreign Key

This connects the tables.

STUDENT │ │ Student_ID ▼ REGISTRATION
Memory:

> Foreign Key = Connection between tables
6. Composite Key

A Composite Key consists of two or more attributes together that uniquely identify a record.

Example:
REGISTRATION ------------------- Student_ID Course_ID

A student can register for multiple courses.

The combination:

Student_ID + Course_ID

can uniquely identify a registration for a particular student-course combination.

Memory:

> Composite = Combination of keys
C. Constraints

Constraints are rules applied to data to maintain correctness and consistency.

Easy memory:

> Constraint = Rule
1. Domain Constraint

Specifies the valid values that an attribute can contain.

Example:
Marks → 0 to 100
Age → Positive number

Marks = 150 ❌
Marks = 85  ✅
2. Key Constraint

Ensures that key values uniquely identify records.

Example:
Student_ID 101 102 103

Duplicate Student IDs are not allowed for a primary key.

3. Entity Integrity Constraint

A primary key cannot contain NULL.

Student_ID = NULL ❌

Every student must have a valid identifier.

Memory:

> Entity Integrity = Primary Key cannot be NULL
4. Referential Integrity Constraint

A foreign key must refer to an existing primary key value in the related table, subject to the database's referential-action rules.

Example:
STUDENT Student_ID 101 102 If REGISTRATION.Student_ID = 101: 101 exists → ✅ If: REGISTRATION.Student_ID = 999 and 999 doesn't exist in STUDENT: 999 → ❌
Memory:

> Referential Integrity = Foreign Key must refer to valid parent data
5. NOT NULL Constraint

Ensures that a column cannot have a NULL value.

Name VARCHAR(50) NOT NULL

A student's name must be provided.

6. UNIQUE Constraint

Ensures that values in a column are not duplicated.

Email VARCHAR(100) UNIQUE

Two students cannot have the same email, if the constraint is defined this way.

7. CHECK Constraint

Ensures that values satisfy a condition.

Marks INT CHECK (Marks >= 0 AND Marks <= 100)

Therefore:

Marks = 85   → ✅
Marks = 150 → ❌
8. DEFAULT Constraint

Provides a default value when no value is supplied.

Semester VARCHAR(10) DEFAULT 'I'

If no semester is entered:

Semester = I
9. Analyze Mapping Cardinality in an E-R Model
1. Mapping Cardinality

Mapping Cardinality describes how many entities of one entity set can be associated with how many entities of another entity set.

Simple meaning:

> Cardinality = How many are connected to how many?
For example:
STUDENT ───── COURSE

We ask:

> How many courses can one student take?
How many students can take one course?

Based on the answer, there are four types:

1. One-to-One (1:1)

2. One-to-Many (1:N)

3. Many-to-One (N:1)

4. Many-to-Many (M:N)

⭐ Easy Memory

> 1:1 → One ↔ One
1:N → One → Many
N:1 → Many → One
M:N → Many ↔ Many
2. One-to-One Relationship (1:1)

In a one-to-one relationship, one entity in Entity A is related to only one entity in Entity B, and vice versa.

Example: Person and Passport

One person has one passport.

One passport belongs to one person.

E-R Diagram
┌──────────────┐ ┌──────────────┐ │ PERSON │ 1 1 │ PASSPORT │ │──────────────│──────────│──────────────│ │ Person_ID PK │ │ Passport_ID │ │ Name │ │ Issue_Date │ └──────────────┘ └──────────────┘

Example data

Person 101 → Passport P101 Person 102 → Passport P102

Another example

EMPLOYEE 1 ───── 1 COMPANY_ID_CARD

One employee has one company ID card.

Memory:

> 1:1 = One person → One thing
3. One-to-Many Relationship (1:N)

In a one-to-many relationship, one entity in Entity A can be related to many entities in Entity B.

But each entity in B is related to only one entity in A.

Example: Department and Employee

One department can have many employees.

But each employee belongs to one department.

E-R Diagram
┌──────────────┐ ┌──────────────┐ │ DEPARTMENT │ 1 N │ EMPLOYEE │ │──────────────│───────────────│──────────────│ │ Dept_ID PK │ │ Employee_ID │ │ Dept_Name │ │ Name │ └──────────────┘ │ Dept_ID FK │ └──────────────┘

Example

AI&ML Department │ ├── Arun ├── Ravi ├── Priya └── Kumar

One department → Many employees.

Memory:

> 1:N = One → Many
4. Many-to-One Relationship (N:1)

A many-to-one relationship is the reverse of one-to-many.

Many entities in Entity A are related to one entity in Entity B.

Example: Employees and Department

Many employees belong to one department.

EMPLOYEE │ ├──────┐ ├──────┤ ├──────┤ └──────┤ ▼ DEPARTMENT
E-R Diagram
┌──────────────┐ ┌──────────────┐ │ EMPLOYEE │ N 1 │ DEPARTMENT │ │──────────────│───────────────│──────────────│ │ Employee_ID │ │ Dept_ID PK │ │ Name │ │ Dept_Name │ │ Dept_ID FK │ └──────────────┘ └──────────────┘

Example

Arun ──┐ Ravi ──┤ Priya ──┼──→ AI&ML Department Kumar ──┘

Many employees → One department.

Memory:

> N:1 = Many → One
5. Many-to-Many Relationship (M:N)

In a many-to-many relationship, many entities in Entity A can be related to many entities in Entity B.

Example: Student and Course

One student can register for many courses.

One course can have many students.

E-R Diagram
┌──────────────┐ ┌──────────────┐ │ STUDENT │ M N │ COURSE │ │──────────────│───────┐ ┌───│──────────────│ │ Student_ID │ │ │ │ Course_ID │ │ Name │ │ │ │ Course_Name │ └──────────────┘ │ │ └──────────────┘ │ │ ┌─────▼───▼─────┐ │ REGISTRATION │ └───────────────┘

A better relational representation is:

STUDENT 1 ─── N REGISTRATION N ─── 1 COURSE

Example

Arun ├── DBMS ├── Java └── AI Ravi ├── DBMS └── Java

So:

Student → Many Courses
Course → Many Students
Memory:

> M:N = Many ↔ Many
6. Comparison of Mapping Cardinalities
Cardinality Meaning Example
1:1 One entity ↔ One entity Person–Passport
1:N One entity → Many entities Department–Employee
N:1 Many entities → One entity Employee–Department
M:N Many entities ↔ Many entities Student–Course
7. How to Identify Cardinality in an Exam

Ask two questions.

Question 1:

> How many B's can one A have?

Question 2:

> How many A's can one B have?
For example:

Student ↔ Course

One student → ?

Many courses.

One course → ?

Many students.

> M:N
Department ↔ Employee

One department → ?

Many employees.

One employee → ?

One department.

> 1:N
Person ↔ Passport

One person → ?

One passport.

One passport → ?

One person.

> 1:1
⭐ Super Memory Trick

Think of the arrows:

1 : 1 → One ↔ One
1 : N → One → Many
N : 1 → Many → One
M : N → Many ↔ Many

And remember:

> "Ask both sides: How many?"

That is the easiest way to identify mapping cardinality.
10. ER Model for Bank Management System and Conversion into Relational Schema

For a Bank Management System, we need to store information about:

Customers

Accounts

Branches

Loans

Transactions

1. Identify Main Entities

The main entities are:

1. CUSTOMER

2. ACCOUNT

3. BRANCH

4. LOAN

5. TRANSACTION

2. CUSTOMER Entity

A customer has:

Customer_ID

Customer_Name

Address

Phone

Email

Primary Key:

> Customer_ID
3. ACCOUNT Entity

An account has:

Account_No

Account_Type

Balance

Open_Date

Primary Key:

> Account_No
4. BRANCH Entity

A bank branch has:

Branch_ID

Branch_Name

Location

Primary Key:

> Branch_ID
5. LOAN Entity

A loan has:

Loan_ID

Loan_Type

Amount

Loan_Date

Primary Key:

> Loan_ID
6. TRANSACTION Entity

A transaction has:

Transaction_ID

Transaction_Date

Transaction_Type

Amount

Primary Key:

> Transaction_ID
7. Identify Relationships

Now determine how the entities are connected.

Customer – Account

A customer can have many accounts.

An account can also be jointly owned by multiple customers in a banking system.

Therefore:

> CUSTOMER ↔ ACCOUNT = M:N

We can use an intermediate relationship/table such as CUSTOMER_ACCOUNT.

Branch – Account

One branch manages many accounts.

Each account belongs to one branch.

Therefore:

> BRANCH → ACCOUNT = 1:N
Customer – Loan

A customer can have multiple loans.

A loan can potentially have multiple borrowers in a system that supports joint loans.

Therefore:

> CUSTOMER ↔ LOAN = M:N

For a simple exam model, if your syllabus assumes one loan belongs to one customer, you may instead represent it as CUSTOMER 1:N LOAN. The M:N design is more flexible.

Account – Transaction

One account can have many transactions.

Each transaction belongs to one account.

Therefore:

> ACCOUNT → TRANSACTION = 1:N
8. Complete ER Diagram
┌──────────────────┐ │ BRANCH │ │──────────────────│ │ PK Branch_ID │ │ Branch_Name │ │ Location │ └────────┬─────────┘ │ │ 1 │ │ N ┌────────▼─────────┐ │ ACCOUNT │ │──────────────────│ │ PK Account_No │ │ Account_Type │ │ Balance │ │ Open_Date │ │ FK Branch_ID │ └───────┬──────────┘ │ │ 1 │ │ N ┌───────▼──────────┐ │ TRANSACTION │ │──────────────────│ │ PK Transaction_ID│ │ Transaction_Date │ │ Transaction_Type │ │ Amount │ │ FK Account_No │ └──────────────────┘ ┌──────────────────┐ │ CUSTOMER │ │──────────────────│ │ PK Customer_ID │ │ Customer_Name │ │ Address │ │ Phone │ │ Email │ └────────┬─────────┘ │ │ M │ ┌──────▼──────────┐ │ CUSTOMER_ACCOUNT│ │─────────────────│ │ PK/FK Customer_ID│ │ PK/FK Account_No │ └──────┬──────────┘ │ │ M │ ▼ ACCOUNT ┌──────────────────┐ │ LOAN │ │──────────────────│ │ PK Loan_ID │ │ Loan_Type │ │ Amount │ │ Loan_Date │ └────────┬─────────┘ │ │ CUSTOMER ↔ LOAN (M:N)

For an exam, you can draw the entities as rectangles, attributes as ovals, and relationships as diamonds if your faculty expects the traditional Chen notation.

9. Traditional ER Representation

You can represent the major relationships like this:

┌───────────┐ │ BRANCH │ └─────┬─────┘ │ MANAGES │ 1:N │ ┌─────▼─────┐ │ ACCOUNT │ └─────┬─────┘ │ HAS / MAKES │ 1:N │ ┌─────▼─────┐ │TRANSACTION│ └───────────┘ ┌───────────┐ OWNS ┌───────────┐ │ CUSTOMER │ M ───────────── N │ ACCOUNT │ └───────────┘ └───────────┘ ┌───────────┐ TAKES ┌───────────┐ │ CUSTOMER │ M ───────────── N │ LOAN │ └───────────┘ └───────────┘
10. Conversion of ER Model into Relational Schema

The basic conversion rules are:

Rule 1: Strong Entity → Table

Each strong entity becomes a table.

Rule 2: Attributes → Columns

Each attribute becomes a column.

Rule 3: Primary Key → Primary Key

The identifying attribute becomes the table's primary key.

Rule 4: 1:N Relationship

Put the primary key of the 1-side into the N-side as a foreign key.

Rule 5: M:N Relationship

Create a new table containing the primary keys of both entities.

11. Convert CUSTOMER

ER Entity:

CUSTOMER

Relational Schema:

CUSTOMER( Customer_ID PK, Customer_Name, Address, Phone, Email )
12. Convert BRANCH
BRANCH( Branch_ID PK, Branch_Name, Location )
13. Convert ACCOUNT

The relationship is:

BRANCH 1 ───── N ACCOUNT

So Branch_ID is added to the ACCOUNT table as a foreign key.

ACCOUNT( Account_No PK, Account_Type, Balance, Open_Date, Branch_ID FK )

Why?

> 1:N → Put the 1-side key into the N-side
14. Convert TRANSACTION

Relationship:

ACCOUNT 1 ───── N TRANSACTION

Therefore, Account_No becomes a foreign key in TRANSACTION.

TRANSACTION( Transaction_ID PK, Transaction_Date, Transaction_Type, Amount, Account_No FK )
15. Convert CUSTOMER–ACCOUNT M:N

Because:

CUSTOMER M ───── N ACCOUNT

we create a new table:

CUSTOMER_ACCOUNT( Customer_ID PK, FK, Account_No PK, FK )

The combination:

Customer_ID + Account_No

can serve as a composite primary key.

16. Convert CUSTOMER–LOAN M:N

Create a new table:

CUSTOMER_LOAN( Customer_ID PK, FK, Loan_ID PK, FK )

Again:

Customer_ID + Loan_ID

forms a composite key for the relationship table.

17. Convert LOAN
LOAN( Loan_ID PK, Loan_Type, Amount, Loan_Date )
⭐ Final Relational Schema
CUSTOMER ( Customer_ID PK, Customer_Name, Address, Phone, Email ) BRANCH ( Branch_ID PK, Branch_Name, Location ) ACCOUNT ( Account_No PK, Account_Type, Balance, Open_Date, Branch_ID FK ) TRANSACTION ( Transaction_ID PK, Transaction_Date, Transaction_Type, Amount, Account_No FK ) LOAN ( Loan_ID PK, Loan_Type, Amount, Loan_Date ) CUSTOMER_ACCOUNT ( Customer_ID PK, FK, Account_No PK, FK ) CUSTOMER_LOAN ( Customer_ID PK, FK, Loan_ID PK, FK )
18. SQL Table Creation

You can also demonstrate the relational schema using SQL:

CREATE TABLE Customer ( Customer_ID INT PRIMARY KEY, Customer_Name VARCHAR(50), Address VARCHAR(100), Phone VARCHAR(15), Email VARCHAR(100) ); CREATE TABLE Branch ( Branch_ID INT PRIMARY KEY, Branch_Name VARCHAR(50), Location VARCHAR(100) ); CREATE TABLE Account ( Account_No INT PRIMARY KEY, Account_Type VARCHAR(20), Balance DECIMAL(12,2), Open_Date DATE, Branch_ID INT, FOREIGN KEY (Branch_ID) REFERENCES Branch(Branch_ID) ); CREATE TABLE Transaction_Table ( Transaction_ID INT PRIMARY KEY, Transaction_Date DATE, Transaction_Type VARCHAR(20), Amount DECIMAL(12,2), Account_No INT, FOREIGN KEY (Account_No) REFERENCES Account(Account_No) ); CREATE TABLE Loan ( Loan_ID INT PRIMARY KEY, Loan_Type VARCHAR(30), Amount DECIMAL(12,2), Loan_Date DATE ); CREATE TABLE Customer_Account ( Customer_ID INT, Account_No INT, PRIMARY KEY (Customer_ID, Account_No), FOREIGN KEY (Customer_ID) REFERENCES Customer(Customer_ID), FOREIGN KEY (Account_No) REFERENCES Account(Account_No) ); CREATE TABLE Customer_Loan ( Customer_ID INT, Loan_ID INT, PRIMARY KEY (Customer_ID, Loan_ID), FOREIGN KEY (Customer_ID) REFERENCES Customer(Customer_ID), FOREIGN KEY (Loan_ID) REFERENCES Loan(Loan_ID) );