DB
DB
“Data” is raw, unorganized facts that by themselves do not convey any When processed → “Kar k scored 78 marks in year 2025 with grade A.”
specific meaning. ये informa on बन जाती है ।
It is the lowest level representa on of informa on.
Data can be: 2. Informa on (EXTREME DETAIL)
Numbers (45, 98.27) Informa on is the processed, refined, structured form of data
Text (Kar k, Haryana) which has:
views
indexes 5. Advantages of DBMS (EXTREME DETAIL)
schema 1. Data Redundancy Controlled
2. Data storage management No duplicate data.
Data saved in op mized formats → blocks, pages Same data stored only once → saves memory.
SQL queries: SELECT, JOIN, WHERE, ORDER BY If one copy updates → all users see updated data.
No mismatching values.
4. Data manipula on
Example:
Changing data (INSERT, UPDATE, DELETE)
Bank account balance remains same in ATM, UPI, branch.
5. Transac on management
3. Enhanced Security
Ensures ACID proper es:
DBMS provides: 7. Data Independence
Authen ca on Physical storage changes → program doesn’t change.
Authoriza on
Encryp on 6. Disadvantages of DBMS (EXTREME DETAIL)
Firewalls High Cost
Every user gets only necessary access. Setup cost = hardware + so ware + staff
4. Data Sharing High Complexity
Many users access database together without errors. Large systems require deep understanding.
Example:
Large Memory & Space
Thousands of people book train ckets simultaneously.
Indexes + logs + metadata consume more memory.
5. Backup & Recovery
Technical Staff Needed
Auto-backups protect from:
DBAs, developers, analysts required.
system crash
power failure
7. DBMS Users (EXTREME DETAIL)
accidental delete
1. Database Administrator (DBA)
DBMS restores last stable version.
Most powerful user.
6. Data Integrity
DBA Responsibili es:
DBMS uses constraints:
Create database structure
NOT NULL
Set access permissions
UNIQUE
Ensure security
PRIMARY KEY
Monitor performance
FOREIGN KEY
Manage backups
These ensure correctness of data.
Handle recovery they interact with DB using SQL.
Maintain documenta on
DBA = “Database का Boss” 8. DBMS Architecture (EXTREME DETAIL)
This is the most important 15-marks topic.
2. End Users DBMS uses 3-level architecture to give:
Normal users: security
Students checking results data independence
Customers using ATM simplicity
Online shoppers
They interact through applica on interfaces. Level 1: Physical Level (Internal Level)
It defines HOW data is stored physically:
3. System Analysts storage blocks
They design: file structures
database requirements indexes
data flow byte-level storage
business logic access paths
Users never see this level.
4. Applica on Programmers DBA handles it.
PHP It describes:
C# tables
columns
data types 9. Schema & Instance (EXTREME DETAIL)
rela onships Schema
keys Schema = Structure / Blueprint of database
constraints It defines:
Example: columns
STUDENT(roll, name, age, marks) data types
rela onships
Level 3: View Level (External Level) Schema is sta c (rarely changes)
Defines WHAT part of database each user sees. Example:
Example: STUDENT(roll, name, age)
Accountant sees fee details Instance = Actual data stored RIGHT NOW
Instance changes frequently.
Example:
Why 3-level architecture?
roll name age
Because:
1 K 20
It protects data
2 Aman 21
It hides complexity
It improves security
It allows independent changes Schema = Design
Instance = Data inside design
It supports mul ple user views
Why are Data Models Needed? (Deep Explana on)
10. Data Independence (EXTREME DETAIL) 1. They give a clear structure to data.
Data independence means: 2. Help in database designing.
Change in storage does not affect applica on 3. Define rela onships between data.
Change in logical structure does not affect user view 4. Ensure consistency and accuracy.
Types: 5. Reduce complexity of large data.
1. Physical Data Independence 6. Provide a standardized approach to represent data.
UNIT–II (Extreme Detailed Notes – 15 Marks Level) Searching is fast but structure is rigid.
CAD Department
5. Derived A ribute
2. One-to-Many (1:N)
Values calculated from another value.
One en ty relates to mul ple en es.
Examples:
Example:
Age (derived from DOB)
One teacher → teaches many students
Total marks (from individual marks)
Shown as → do ed circle.
3. Many-to-One (N:1)
Example:
6. Key A ribute
Many students → assigned to one class teacher
Uniquely iden fies an en ty.
Example: RollNo, EmployeeID
4. Many-to-Many (M:N)
Shown as → a ribute with underline.
Both sides have mul ple connec ons.
Example:
6. RELATIONSHIPS (EXTREMELY DETAILED)
Students ↔ Courses
A student takes many courses 1:N
A course has many students N:1
Most important rela onship. M:N
Cardinality is the backbone of ER modeling.
7. RELATIONSHIP DEGREE (Extreme Detail)
Degree = number of en es par cipa ng. 9. KEYS (Extreme Detail)
1. Unary Rela onship Keys uniquely iden fy data in rela onal model.
En ty relates to itself. Types of Keys
Example: Employee → manages → Employee
1. Super Key
2. Binary Rela onship
Any a ribute that uniquely iden fies a tuple.
Between two en es.
2. Candidate Key
Most common.
Minimal super key (no extra a ribute).
Example: Student → gives → Exam
3. Primary Key
3. Ternary Rela onship
Chosen candidate key
Three en es involved.
Unique + Not Null
Example:
Doctor, Pa ent, Medicine 4. Foreign Key
Primary key of another table used to link tables.
3. Primary Key
2. KEYS IN RELATIONAL MODEL (EXTREME DETAIL)
A chosen candidate key that uniquely iden fies tuples.
Keys uniquely iden fy tuples in a table.
Proper es:
Understanding keys is extremely important for database integrity.
Must be unique
Cannot be NULL
1. Super Key
Should be stable (not change over me)
A super key is any set of a ributes that can uniquely iden fy a tuple.
Example:
Example:
roll
{roll}
employee_id
Integrity constraints maintain accuracy, consistency, and reliability of
the data.
4. Foreign Key
A foreign key creates a link between two tables.
Defini on: 1. Domain Integrity
A foreign key is an a ribute in one table that refers to the primary key Ensures values must be from a defined domain.
of another table. Example:
Example: Age must be between 1–120
STUDENT Table Gender must be “M”, “F”, “O”
Roll | Name
MARKS Table 2. En ty Integrity
4. Right Join
All rows from right table + matching rows from le . Defini on (Exam-Worthy 15 Marks Defini on)
4. Par al Dependency
Types of Func onal Dependencies (Full Deep Explana on) When a part of a composite key determines a non-key a ribute.
Example: Example:
Key = {Roll, Subject} FDs:
FD: Roll → StudentName A→B
This is par al, because only part of key (Roll) determines something. B→C
NOTE:
A rela on is in 3NF if: Break into two tables.
✔ It is in 2NF
✔ No transi ve dependency
5NF (Fi h Normal Form)
If A → B and B → C
Also called Project-Join Normal Form.
Then A → C is transi ve, which must be removed.
Used when:
Solu on:
✔ Data is broken into too many small tables
Break table to remove transi ve dependency.
✔ Lossless join must be ensured
Used in extremely complex databases.
BCNF (Boyce-Codd Normal Form)
A rela on is in BCNF if:
For every FD X → Y, X must be a candidate key. 6. LOSSLESS JOIN (VERY DEEP)
7. DEPENDENCY PRESERVATION
4NF (Fourth Normal Form) A er spli ng a table, all original FDs must s ll be enforceable.
A rela on is in 4NF if: Example:
✔ It is in BCNF If FD A → B exists
✔ It has no mul valued dependency (MVD) Then a er decomposi on, A and B must appear together or FD must
be enforceable.
Used when en ty has mul -valued a ributes.
Example:
Student →→ Phone 8. SQL COMMANDS (EXTREME DEEP EXPLANATION)
Student →→ Skill
SQL has five categories: Used for retrieving data.
Only command:
1. DDL – Data Defini on Language SELECT
Used for table structure.
Commands: 4. DCL – Data Control Language
CREATE Used for security.
DROP Commands:
ALTER GRANT
RENAME REVOKE
TRUNCATE
Examples: 5. TCL – Transac on Control Language
CREATE TABLE STUDENT (roll INT, name VARCHAR(50));
Used for transac on management.
ALTER TABLE STUDENT ADD age INT;
Commands:
COMMIT
2. DML – Data Manipula on Language ROLLBACK
Used for modifying data. SAVEPOINT
Commands:
INSERT
9. SQL CONSTRAINTS (DEEP DETAIL)
UPDATE
Used to enforce rules on data.
DELETE
Types:
MERGE
1. PRIMARY KEY
2. FOREIGN KEY
3. DQL – Data Query Language 3. NOT NULL
4. UNIQUE intermediary between the user and the database, ensuring data
5. CHECK consistency, security, and integrity. DBMS performs mul ple func ons
such as defining data, storing data, retrieving data, upda ng data, and
6. DEFAULT
managing transac ons. DBMS supports mul ple users simultaneously
while ensuring that their opera ons do not conflict.
UNIT – I DBMS offers several advantages over old file-based systems. First,
data redundancy is reduced because data is not stored repeatedly in
Q1 (500+ words): Explain the basic introduc on of DBMS including
mul ple files. This also leads to data consistency, ensuring that all
data, informa on, database, database system, advantages,
users see the same updated data. DBMS improves data security by
disadvantages, DBMS users, and 3-level architecture in detail.
defining access rules, user permissions, encryp on, and
ANSWER (SUPER-DETAILED – 500+ WORDS) authen ca on. It supports data sharing, enabling several users to
A Database Management System (DBMS) is a sophis cated so ware work on the same data concurrently. Another major advantage is
system designed to manage, store, retrieve, and manipulate data backup and recovery, as DBMS automa cally maintains logs and
efficiently. To understand DBMS completely, one must begin from the backups to restore data in case of failure. DBMS also ensures data
most fundamental element: data. Data refers to raw, unprocessed integrity through constraints like primary key, foreign key, and unique
facts which do not carry any inherent meaning. For example, numbers key.
like “45”, “2025”, or words like “Rahul”, “Delhi” are considered raw Despite the advantages, DBMS has limita ons. It is expensive to
data because they lack context. When data is processed, organized, install and maintain. It requires skilled staff like DBAs, system
and given meaning, it transforms into informa on. For instance, analysts, and applica on programmers. DBMS also requires large
“Rahul scored 45 marks in 2025” is meaningful because the raw data memory and high processing power, especially for large organiza ons.
is now structured into a useful statement. The system can become overly complex for small setups.
A database is a structured collec on of related data stored in an DBMS users are categorized into several types. Database
organized manner. This data is stored in such a way that it becomes Administrators (DBAs) manage the database, handle security, allocate
easy to access, update, and manage. Without structure, large volumes storage, manage backup, and ensure performance. End-users interact
of data would be meaningless. Databases store everything—from with the database through applica ons such as ATM, online shopping
student records and banking transac ons to airline reserva ons and apps, or student portals. Applica on programmers write programs in
online shopping data. Java, Python, C#, PHP, etc., and interact with the DBMS using SQL.
A database system consists of the database itself, the DBMS so ware, System analysts understand the organiza on’s requirements and
hardware, users, and applica on programs. DBMS acts as an prepare database design specifica ons.
One of the most important features of DBMS is the 3-Level limita ons by introducing a structured, consistent, and secure way to
Architecture proposed by ANSI/SPARC to provide abstrac on and store and manage data. To understand DBMS deeply, we must begin
data independence. The lowest level is the Physical (Internal) Level, from the core concepts such as data, informa on, and database.
which defines how data is physically stored in files, blocks, indexes, Data is defined as raw, unorganized, unprocessed facts that by
and memory. The Logical (Conceptual) Level describes what data is themselves do not carry any meaning. Data can be numbers, text,
stored and how the data is related. This level defines tables, symbols, images, audio, or video. For example, the numbers “76”,
a ributes, rela onships, and constraints. The highest level is the View “2025”, “Kar k”, “BCA”, etc., are just data. They do not describe any
(External) Level, which defines what a specific user can see. A student meaningful rela onship and thus cannot be used for decision-making.
can see only their marks; a teacher can see all marks; an accountant Data is the lowest level of abstrac on in any system. On the other
can see fee details. hand, Informa on is the processed, structured, and meaningful form
This architecture hides the complexity of physical storage from users of data. When data is organized, interpreted, analysed, and presented
and provides data independence, meaning changes in storage do not in a useful context, it becomes informa on. For example, “Kar k
affect the user’s view or applica on program. Overall, DBMS is an scored 76 marks in DBMS in 2025” is informa on, because it carries
essen al technology in modern informa on systems, enabling secure, meaning and assists in making conclusions.
efficient, and reliable handling of massive datasets used across A Database is a structured collec on of logically related data stored
industries. systema cally so that it can be retrieved, modified, and managed
efficiently. Unlike tradi onal file systems where data is sca ered and
1: Explain the basic introduc on of DBMS including data, informa on, isolated, a database stores data in an integrated way so that different
database, database system, advantages, disadvantages, DBMS users, users and applica ons can work on the same dataset without conflict.
and the 3-level architecture in deep detail. Databases store informa on such as student records, bank account
details, hospital pa ent informa on, online shopping orders, railway
(Now I will write a full 500–1000+ word long answer)
reserva on details, etc.
A Database System includes the database, the DBMS so ware,
ANSWER (EXTREMELY DETAILED, 500+ WORDS) hardware, users, applica on programs, and procedures. DBMS acts as
an interface between the database and users or applica ons. It
A Database Management System (DBMS) is one of the most
ensures data consistency, security, integrity, and performance. The
fundamental pillars of modern informa on systems. Before the
DBMS allows users to define the structure of data, manipulate data,
inven on of DBMS, organiza ons used tradi onal file systems which
store data in efficient formats, manage transac ons, and provide
had numerous problems, including redundancy, inconsistency, low
controlled access to data.
security, and lack of mul -user support. DBMS solved all these
DBMS offers mul ple advantages over tradi onal file systems. The One of the most important concepts in DBMS is the 3-Level
first major advantage is the reduc on of data redundancy. In Architecture, which provides abstrac on and data independence. The
tradi onal systems, the same data may be stored in mul ple files, lowest level is the Physical Level (Internal Level), which describes how
was ng memory and causing inconsistency. DBMS eliminates data is stored physically in files, blocks, and indexes. Users do not
redundancy by storing data only once and linking related objects interact with this level. The middle level is the Logical Level
logically. Second, DBMS ensures data consistency, meaning that every (Conceptual Level), describing what data is stored and the
user sees the same, updated, correct version of data. Third, DBMS rela onships among them. This level includes tables, a ributes,
supports data security through encryp on, authoriza on, constraints, and keys. The highest level is the View Level (External
authen ca on, and permissions, preven ng unauthorized access. Level), which defines what por on of data each user can access. For
Fourth, DBMS supports mul -user environments through concurrency example, a student may only see his own marks; an accountant may
control, ensuring that many users can access the database only see fee details.
simultaneously without interfering with each other’s transac ons. This architecture provides data independence, meaning changes at
Addi onally, DBMS provides backup and recovery, restoring data in one level do not affect the other levels. Physical changes do not affect
case of system crashes, power failures, or corrup on. It also enforces logical structure, and logical changes do not affect user views.
data integrity using rules like primary keys and foreign keys.
In conclusion, DBMS is an essen al tool for managing large datasets in
However, DBMS also has disadvantages. It requires high ini al cost for a secure, consistent, and efficient manner. It overcomes file system
purchasing the so ware and hardware. It needs large memory and limita ons and provides a complete environment for data storage,
storage for indexes, logs, and metadata. Skilled personnel such as manipula on, retrieval, and protec on.
DBAs and programmers are required to set up, configure, and
maintain the system. DBMS can also be complex for small
organiza ons. Unit–I → Ques on 2 (PYQ Based, 500+ Words)
There are several types of DBMS users. The most powerful user is the Q2: Compare the File-Based System with the Database Management
Database Administrator (DBA), who handles the en re database, System (DBMS). Explain all types of anomalies in File-Based Systems
manages security, creates backup plans, monitors performance, and and describe how DBMS solves each of them in detail.
allocates resources. End users interact with the database indirectly
through applica ons like ATM machines, mobile apps, or web portals.
Applica on programmers develop so ware using languages like Java, ANSWER (FULL 500+ WORDS, VERY DEEP & EXAM PERFECT)
Python, or PHP and interact with DBMS using SQL. System analysts Before the inven on of DBMS, organiza ons used the tradi onal File-
study organiza onal requirements and design the database structure. Based System to store data. In this system, data was stored in
separate files such as text files, spreadsheets, or simple applica on- In file systems, files are isolated and can only be accessed by
specific files. Each applica on had its own files and handled its own individual applica ons. This makes data sharing extremely difficult.
data independently. This approach was simple but resulted in several DBMS solves this by allowing mul ple users and applica ons to
major problems such as redundancy, inconsistency, low security, poor access the same centralized data.
sharing, and the presence of anomalies. DBMS was created to
eliminate all these weaknesses and provide a powerful, centralized,
4. Poor Security
and consistent way of managing data.
File systems have primi ve security measures. Anyone with access to
files can modify or delete data.
Difference Between File System & DBMS (Deep Explana on) DBMS solves this through authen ca on, authoriza on, encryp on,
1. Data Redundancy privileges, views, and role-based access.
In file systems, the same data is stored in mul ple files. For example,
a student’s name and address may appear in a endance files, exam 5. No Data Independence
files, hostel files, and library records. This duplica on wastes storage
File systems store data and programs together. If data format
space.
changes, applica on programs also must change.
DBMS solves this by storing data in normalized tables and linking
DBMS solves this using 3-Level Architecture which separates data
them with keys. The data appears only once and is referenced
from applica ons, guaranteeing logical and physical data
everywhere using foreign keys.
independence.
2. Data Inconsistency
6. Concurrency Issues
Since file systems store mul ple copies of the same data, if one copy
File systems cannot handle mul ple users accessing files
is updated and others are not, inconsistent data emerges. For
simultaneously. This leads to overwri ng, conflicts, and corrup on.
example, a student’s phone number may be updated in hostel records
DBMS solves this using concurrency control and transac on
but not in fee records.
management.
DBMS solves this by ensuring that one centralized copy of the data
exists.
Data Anomalies in File-Based Systems (EXTREMELY IMPORTANT)
3. Lack of Data Sharing
Data anomalies are inconsistencies or problems that occur during DBMS stores data in normalized, separate tables, so dele ng one
inser on, dele on, or upda ng in a poorly designed system. record does not remove unrelated informa on.
There are three major anomalies:
3. Update Anomaly
1. Inser on Anomaly (Deep Explana on) This occurs when a single update must be made in mul ple places.
Inser on anomaly occurs when certain data cannot be inserted into Example:
the database because some other data is missing. If a student's address is stored in five different files, upda ng it
Example: requires five updates. If one is missed, inconsistency occurs.
Suppose a file stores Student + Course informa on together. DBMS Solu on:
If a new course is introduced but no student has enrolled yet, the DBMS ensures that each data item is stored only once. Upda ng that
course details cannot be inserted unless you also insert a dummy single loca on automa cally ensures consistency.
student.
DBMS Solu on:
How DBMS Eliminates Anomalies (Deep Summary)
DBMS separates data into mul ple related tables using normaliza on.
Course table and Student table become independent, so new courses ✔ Through Normaliza on (1NF → BCNF)
can be inserted without needing student data. ✔ Through Keys (Primary & Foreign)
✔ Through Centralized data storage
✔ Through Rela onships between tables
2. Dele on Anomaly
✔ Through Data Independence
This occurs when dele ng one piece of data uninten onally deletes ✔ Through Referen al Integrity
other important data.
Example:
Conclusion
If a student drops their last enrolled course, dele ng that record may
also delete their personal informa on. The file-based system is simple but suffers from serious limita ons
including redundancy, inconsistency, lack of security, and anomalies.
DBMS Solu on:
DBMS eliminates these weaknesses through centralized storage,
normalized structure, constraints, and strong data management
capabili es. DBMS not only removes anomalies but also ensures one parent, but a single parent can have mul ple children, forming a
accuracy, efficiency, and reliability of modern data systems, making it one-to-many (1:N) rela onship.
essen al for banks, colleges, hospitals, railways, e-commerce, and Imagine the structure as an inverted tree:
every large-scale data-driven organiza on.
Parent (Root)
|
UNIT–II → Ques on 3 (500+ words)
--------------
Q3: Explain the different types of Data Models in detail. Describe the
| | |
Hierarchical Model, Network Model, and Rela onal Model with deep
explana on, structure, advantages, disadvantages, and real-world Child Child Child
examples. ✔ Characteris cs:
Data stored as nodes
ANSWER (EXTREMELY DETAILED – 600+ WORDS) Parent-child rela onships
A Data Model is a conceptual framework used to describe and One parent → many children
structure data in a database system. It provides a clear way to
Child cannot exist without parent
represent data, the rela onships between data, and the rules that
govern data. Without a data model, data would be sca ered, ✔ Advantages:
inconsistent, and difficult to process. A data model helps in designing 1. Fast data access because the path is predefined.
databases in a logical, systema c, and understandable manner. The
2. Simple structure for applica ons like organiza onal charts.
most common and historically important data models include the
Hierarchical Model, Network Model, and Rela onal Model, each of 3. Good performance for one-to-many rela onships.
which reflects different ways of structuring and managing data. 4. Ensures data integrity through parent-child rules.
✔ Disadvantages:
1. Hierarchical Data Model (Deep Explana on) 1. Rigid structure; changes are difficult.
The Hierarchical Model was the earliest database model used in large 2. Cannot represent many-to-many rela onships.
systems such as banking, industry, and government. In this model,
3. Searching requires knowing the exact path.
data is represented in a tree-like structure, where data is organized
into levels, forming parent-child rela onships. Each child has exactly 4. Child cannot exist independently.
✔ Real-world examples: 3. Efficient for complex data
File system directories 4. Faster access through pointers
The Network Model was introduced to overcome the limita ons of 4. Complex applica on programming
the hierarchical model. It allows data to have mul ple parents, ✔ Real-world examples:
enabling many-to-many (M:N) rela onships. It uses a graph-like
Telecommunica ons networks
structure made of nodes and links (edges).
Transport routes
Example structure:
Airline reserva on paths
A
/ \
B --- C 3. Rela onal Data Model (Very Deep Explana on)
| Roll | Name | Age | Dept | These constraints ensure that the database remains valid, consistent,
and reliable.
Each row represents an individual student.
Combines rela ons based on matching a ributes. Types include
natural join, inner join, outer join, le join, right join.
UNIT–III → Q6 (500+ Words)
Rela onal Algebra helps DBMS op mize queries, making data
Q6: Explain Rela onal Algebra in detail. Discuss Selec on, Projec on,
retrieval efficient.
Join, Cartesian Product, Union, Set Difference, and their importance in
query processing.
UNIT–IV → Q7 (1000+ Words)
ANSWER (500+ WORDS) Q7: Explain Rela onal Database Design in deep detail. Discuss
Func onal Dependencies, A ribute Closure, Canonical Cover,
Rela onal Algebra is a procedural query language used to operate on
Normaliza on (1NF to BCNF), Lossless Join, and Dependency
rela ons. It helps in internal query processing and op miza on. The
Preserva on with examples and deep theory.
fundamental opera ons are:
Selec on (σ)
Selects rows based on a condi on. ANSWER (EXTREMELY DETAILED – 1000+ WORDS)
σ(age > 18)(STUDENT) Rela onal Database Design is the process of organizing data into well-
Projec on (π) structured tables to eliminate redundancy, prevent anomalies,
maintain consistency, and improve efficiency. Good database design is
Selects specific columns.
essen al because poor design leads to inser on, dele on, and update
π(name, age)(STUDENT)
anomalies, making the system unreliable and inefficient.
Union (∪)
Rela onal database design is performed using mul ple tools such as
Combines tuples from two rela ons. Func onal Dependencies (FDs), A ribute Closure, Canonical Cover,
Set Difference (−) and Normal Forms (1NF, 2NF, 3NF, BCNF). These concepts ensure the
database is logically sound and free from anomalies.
Returns tuples in A but not in B.
Cartesian Product (×)
1. Func onal Dependencies (FD)
Combines each tuple of A with each tuple of B.
Func onal dependency is the founda on of rela onal database
Join (⨝)
design. An FD shows the rela onship between a ributes. It is
denoted as:
X→Y X →→ Y means X determines mul ple Y-values.
Meaning: “X func onally determines Y.” This violates 4NF.
If two tuples have the same value of X, then they must have the same FDs help understand how a ributes depend on each other, which is
value of Y. essen al for decomposi on.
Example:
Roll → Name
2. A ribute Closure (X⁺)
Aadhar → Person
CourseID → CourseName A ribute closure is the set of all a ributes that can be determined
using a given set of FDs.
Func onal dependencies help iden fy keys, detect redundancy, and
guide normaliza on. Why is closure important?
✔ To find candidate keys
✔ To detect redundant a ributes
Types of Func onal Dependencies ✔ To check normaliza on
A. Trivial FD ✔ To verify lossless join and dependency preserva on
X → Y is trivial if Y is a subset of X. Example:
Example: {Roll, Name} → Roll. FDs:
B. Non-Trivial FD A→B
B→C
X → Y is non-trivial if Y is NOT part of X.
Find closure of A:
Example: Roll → Age.
Start with A⁺ = {A}
C. Par al Dependency
A → B → Add B
Occurs when part of a composite key determines a non-key a ribute. B → C → Add C
This violates 2NF.
So A⁺ = {A, B, C}
D. Transi ve Dependency
If X → Y and Y → Z, then X → Z.
3. Canonical Cover (Minimal Cover)
This violates 3NF.
A canonical cover is a simplified set of func onal dependencies.
E. Mul valued Dependency (MVD)
It has three proper es:
1. Right side must contain only single a ribute ✔ No repea ng groups
2. No FD should be removable ✔ No mul valued a ributes
✔ No inconsistency Fix:
✔ Efficient updates Break into separate tables:
✔ Good design STUDENT(Roll, StudentName)
MARKS(Roll, Subject, Marks)
Q8: Explain SQL in deep detail. Write a long descrip ve answer Enforce constraints
covering SQL introduc on, characteris cs, data types, SQL subsets Maintain data integrity
(DDL, DML, DQL, DCL, TCL), and explain major commands such as
SQL is case-insensi ve, meaning SELECT and select are the same.
CREATE, ALTER, DROP, TRUNCATE, INSERT, UPDATE, DELETE, and
However, SQL keywords are typically wri en in uppercase for clarity.
SELECT with examples.
2. Characteris cs of SQL
ANSWER (EXTREMELY DETAILED – 1000+ WORDS)
✔ Non-procedural language
Structured Query Language (SQL) is the standard language used to
store, manage, and retrieve data stored in rela onal database SQL does not require algorithms.
systems. SQL is used by nearly all modern rela onal DBMS systems You only tell the DBMS “what you want,” not “how to do it.”
such as MySQL, Oracle, PostgreSQL, SQL Server, and MariaDB. It is
✔ Declara ve nature B. Character/String Data Types
SQL describes what to fetch (columns, rows) with condi ons. CHAR(n) → fixed length
SQL uses indexing, joins, op miza on algorithms, and hashing for fast TIME
results. TIMESTAMP
Used for storing date/ me informa on.
✔ Rich set of commands
D. Boolean Type
SQL has mul ple categories: DDL, DML, DQL, DCL, TCL.
TRUE / FALSE
✔ Supports constraints
E. Binary Types
Ensures accuracy of data using NOT NULL, UNIQUE, CHECK, DEFAULT,
PRIMARY KEY, FOREIGN KEY. BLOB (images, audio, files)
F. Large Object Types
Data types specify the type of values that can be stored in a column. Data types ensure data accuracy and memory op miza on.
Different DBMS support different data types, but common categories
include:
4. SQL Sub-languages (The Heart of SQL)
A. Numeric Data Types
SQL is divided into five categories based on func onality:
INT
FLOAT
A. DDL (Data Defini on Language)
DOUBLE
Used to define database structure — tables, schemas, indexes.
DECIMAL
DDL commands:
Used for numbers, salaries, marks, quan es.
CREATE ALTER TABLE Student ADD marks INT;
ALTER Modify datatype:
DROP ALTER TABLE Student MODIFY age VARCHAR(10);
TRUNCATE Delete a column:
RENAME ALTER TABLE Student DROP COLUMN city;
Let’s explain each in depth. ALTER is used when structural changes are needed.
Commands: DEFAULT
ROLLBACK Example:
Example: );