Professional Documents
Culture Documents
DBMS Notes by Khyati
DBMS Notes by Khyati
DBMS Notes by Khyati
UNIT- 1
Introduction to Database
Database ek aisi systematic collection hoti hai jisme data ko store, organize, aur retrieve kiya
ja sakta hai. Yeh information ko ek structured tarike se manage karta hai, taki users easily access
kar sakein.
Database ke kuch important terms:
1. Data: Database me store hone wala koi bhi information.
2. Database Management System (DBMS): Yeh ek software hai jo database ko create, update,
aur manage karta hai. Examples: MySQL, Oracle, Microsoft SQL Server.
3. Table: Database me data ko organize karne ke liye tables ka use hota hai. Har table ek
specific type ke data ko represent karta hai.
4. Record/Row: Table me har ek entry ko record ya row kehte hain. Yeh ek individual data
point hota hai.
5. Field/Column: Har record me specific information ko represent karne ke liye columns ka
use hota hai. Jaise ki ek student ki details me naam, roll number, aur course.
DATA MODELS
Hierarchical Model
Hierarchical database model ek tree-like structure mein data ko organize karta hai jisme ek root
hota hai, jise sabhi dusre data se link kiya jata hai. Har record database mein ek node ki tarah
hota hai, aur node ke beech mein parent-child links establish hote hain. Is model mein, har
parent ke paas multiple children ho sakte hain, lekin har child ka sirf ek hi parent hota hai. Ye
model intuitive aur samajhne mein aasan hota hai, lekin data badhne par ise manage karna
mushkil ho sakta hai.
[DBMS NOTES BY KHYATI]
Data ek tree jaise structure mein organize hota hai jisme do alag prakar ke data ke beech ek
one-to-many relation hota hai, jaise ki ek department ke paas kai courses, kai teachers, aur
beshak kai students ho sakte hain (jo neeche diagram mein dikhaya gaya hai).
Network Model
Network database model hierarchical model ka extension hai aur ismein complex relationships
ko represent karne ki sujhav di jati hai. Iska use graph structure mein hota hai jisme nodes
records ko aur edges records ke beech ke relationships ko darust karte hain. Hierarchical model
ke vipreet, network model mein ek child record ko ek se zyada parent ho sakte hain. Ye
flexibility complex relationships ko represent karne mein madad karta hai, isliye ise kuch khas
scenarios mein istemal kiya jata hai.
Relational Model
Relational database model data ko tables mein organize karta hai, jisme har table rows aur
columns se bani hoti hai. Har row ek record ko represent karti hai, aur har column ek record ki
attribute ko. Tables ek dusre se common fields ke through relate ho sakte hain, jisse alag-alag
sets ke data ke beech mein ek logic connection ban jata hai. Ye model mathematical set theory
par adharit hai aur aajkal ke database management systems (DBMS) mein widespread istemal
hota hai. Relational model ek sidha aur flexible tareeke se data ko manage karne ka ek popular
tareeka hai.
[DBMS NOTES BY KHYATI]
One-Level Architecture:
o Isko "Single-tier" architecture bhi kehte hain.
o Issme ek hi interface ya layer hoti hai jisme DBMS aur application tightly connect hote
hain.
o Application seedhe data management system se interact karta hai.
Characteristics:
o Sabse simple architecture.
o Abstraction aur concerns ko limit mein rakhta hai.
o Application mein ki gayi changes seedhe data management ko affect kar sakti hain.
Use Cases:
o Small-scale applications jahan complexity kam hoti hai.
Database User
Two-Level Architecture:
Characteristics:
o Improved modularity aur concerns ka better separation.
o Application mein ki gayi changes seedhe DBMS ko affect nahi karti.
o Concurrent user access ko allow karta hai.
Use Cases:
o Medium se lekar large-scale applications jahan complexity badh jaati hai.
Three-Level Architecture:
o Isko "Three-tier" architecture bhi kehte hain.
o User interface aur database management system ke beech ek middleware ya application
server layer add hoti hai.
o Scalability, flexibility, aur maintainability ko enhance karta hai.
Layers:
o User Interface (Presentation): User interaction aur input ko handle karta hai.
o Application Server (Logic): Business logic, processing, aur application-specific
functions ko manage karta hai.
o Database Server (Data): Data storage, retrieval, aur management ko handle karta hai.
Characteristics:
o Concerns aur abstraction mein maximum separation.
o Distributed computing aur scalability ko facilitate karta hai.
o Ek layer mein ki gayi changes doosre layers ko directly affect nahi karti.
Use Cases:
o Large-scale applications jinme complex business logic, distributed users, aur data ho.
[DBMS NOTES BY KHYATI]
Data Abstraction
Data Abstraction ek concept hai jiska istemal programming aur software engineering mein hota
hai. Iska mukhya uddeshya complex systems ko simplify karke, aur users ya developers ke liye
asaan aur samajhne mein madad karna hai. Data Abstraction ek tarah se information hide karke,
sirf zaroori aur relevant details ko dikhane ka kaam karti hai.
Yeh do prakar ki hoti hai:
1. Logical Data Abstraction:
• High-Level View: Users ko system ke internal details se mukt rakhti hai. Jaise ki, ek
database system mein, logical data abstraction table, relationship, aur query ke level par
kaam karega, bina yeh dikhaye ki data physical storage kaise hota hai.
• Simplicity: Users ko sirf un details ko dikhaya jata hai jo unke specific kaam ke liye
zaroori hain, baaki internal complexity chhupi rehti hai.
• Example: Relational Database Management System (RDBMS) logical abstraction
provide karta hai jismein data tables aur relationships ke roop mein dikhaya jata hai,
bina actual storage details dikhaiye.
2. Physical Data Abstraction:
• Low-Level View: Developers ya system architects ke liye hoti hai, jo system ke internal
working aur optimization ke liye important hoti hai.
• Implementation Details: Yeh dikhati hai ki data kaise store hota hai, kis tarah ke
indexing ka istemal hota hai, aur data retrieval kaise hoti hai.
• Example: Ek database system mein, physical data abstraction actual disk storage, file
structures, indexing techniques, etc. ke details provide karta hai.
Importance of Data Abstraction
• Complexity Management: Bade aur complex systems ko manageable pieces mein
divide karke samjhne mein madad karta hai.
• Security: Logical abstraction data ko secure rakhta hai kyun ki users sirf unki specified
access level tak hi pahunch sakte hain.
• Ease of Use: Users ko unnecessary technical complexities se bachata hai, aur sirf unki
specific kaam ke liye relevant information dikhata hai.
• Maintenance: System ko upgrade ya modify karne mein madad karta hai bina overall
functionality ko affect kiye.
Example:
Consider a car as an example of data abstraction. A driver interacts with the car using a simple
interface like the steering wheel, pedals, and dashboard. The driver doesn't need to know the
complex internal workings of the engine, transmission, or electronics. This simplified interface
is a form of data abstraction that allows the driver to use the car without being overwhelmed
by the details of how it operates under the hood.
[DBMS NOTES BY KHYATI]
Data Independence
Data Independence ek concept hai jo database systems mein hota hai aur yeh batata hai ki hum
kaise taur par data ko store aur access karte hain, woh change ho sakta hai bina kisi external
application ya user ko affect kiye.
Yeh do tarikon mein hota h
1. Physical Data Independence:
o Physical Data Independence ka matlab hai ki hum internal schema mein kuch bhi
badlav karein bina conceptual schema ko alter kiye, aur database ka structure same
dikhna chahiye.
o Maan lo, agar hum database system server ke storage size mein koi changes karte hain,
toh hume yeh ensure karna chahiye ki jo conceptual structure hai, woh bina kisi user
interface ya conceptual schema ke change ke, waisa hi dikhe.
o Iska use hota hai conceptual level ko internal levels se separate rakhne ke liye.
o Yeh changes internal level par hote hain, jaise storage size, performance optimization,
lekin user ko yeh changes nahi dikhe. Yeh changes logical interface level par hoti hain.
o Jaise ki agar humare paas ek database hai aur hum uske conceptual view mein kuch
badlav karte hain, for example, kisi table ka structure modify karte hain, toh user jise
data dekh raha hai, usko kuch farak nahi padna chahiye. Uska view waisa hi rehna
chahiye jaise pehle tha.
o Iske use se hum external level ko conceptual view se alag rakh sakte hain.
o Agar hum user interface mein kuch changes karte hain, toh bhi user ko pata nahi chalna
chahiye ki actual database ke structure mein kuch badla hua hai. Yeh changes user
interface level par hoti hain.
[DBMS NOTES BY KHYATI]
Data Definition Language (DDL) ek category hai SQL (Structured Query Language) mein,
jiska istemal database structure ko define aur modify karne ke liye hota hai. DDL commands
databases ke schema (structure) ko control karte hain.
1. CREATE:
• CREATE TABLE: New table create karta hai.
• CREATE DATABASE: Naya database create karta hai.
Ex.
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT
);
2. ALTER:
• ALTER TABLE: Existing table ko modify karta hai.
Ex.
ALTER TABLE Students
ADD COLUMN Grade CHAR(1);
3. DROP:
• DROP TABLE: Table ko delete karta hai.
• DROP DATABASE: Database ko delete karta hai.
Ex.
DROP TABLE Students;
Data Manipulation Language (DML) commands database mein data ko retrieve, insert, update,
aur delete karne ke liye istemal hote hain. DML commands database ke records ke saath kaam
karte hain.
Kuch important DML commands hain:
1. SELECT:
• SELECT: Data retrieve karne ke liye istemal hota hai.
Ex.
SELECT * FROM Students;
2. INSERT:
• INSERT INTO: Naye data ko table mein insert karne ke liye istemal hota
hai.
Ex.
INSERT INTO Students (StudentID, Name, Age) VALUES (1, 'Kundan', 20);
[DBMS NOTES BY KHYATI]
3. UPDATE:
• UPDATE: Existing data ko modify karne ke liye istemal hota hai.
Ex.
UPDATE Students SET Age = 21 WHERE StudentID = 1;
4. DELETE:
• DELETE FROM: Data ko delete karne ke liye istemal hota hai.
Ex.
DELETE FROM Students WHERE StudentID = 1;
Data models
Data models are abstract representations of the structure of a database and the relationships
between its elements. They provide a way to organize and understand the data within a
database. There are several types of data models, each serving different purposes.
Here are three common types:
Data Models
Example: Tables jisme entities (jaise ki customers, products) ko represent kiya jata hai, aur
keys ke through relationships define kiye jate hain.
4. Entity-Relationship Model:
o Yeh entities aur unke relationships ko graphical taur par represent karta hai.
o Entities objects ya concepts hote hain jinme attributes hote hain, aur relationships define
karte hain ki entities kaise judte hain.
Example: Database design ke initial stages mein entities aur unke interactions ko visualize
karne ke liye use hota hai.
5. Object-Oriented Data Model:
o Yeh data ko objects ke roop mein represent karta hai, jo object-oriented programming
ke tarah hota hai.
o Data aur us par kaam karne wale methods ko encapsulate karta hai.
Example: Applications jahan data aur behavior closely linked hote hain, jaise ki object-
oriented programming languages mein.
6. Document-Oriented Data Model:
o Yeh data ko documents (jaise ki JSON ya XML) ke roop mein represent karta hai jo
nested structures ko contain kar sakte hain.
o Semi-structured data ko store aur query karne ke liye suitable hai.
Example: NoSQL databases mein diverse data types ko handle karne ke liye commonly used
hota hai.
Integrity constraints
Integrity constraints database management system mein data consistency, accuracy, aur
reliability ko maintain karne ke liye use hone wale rules aur restrictions hote hain. Ye
constraints ensure karte hain ki database mein stored data specified rules ke mutabiq ho aur
unwanted ya inconsistent data ko prevent karte hain. Kuch mukhya types ke integrity
constraints hote hain:
3. Unique Constraint:
- Unique constraint ek column ya set of columns ko unique values hone ki
guarantee deta hai. Duplicate values allow nahi hote.
- Yeh constraint data consistency ko maintain karta hai.
Example:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
UNIQUE (EmployeeID)
);
4. Check Constraint:
- Check constraint ek column mein specific conditions ya expressions ko satisfy
karne ki guarantee deta hai.
- Yeh constraint unwanted data ko prevent karta hai.
Example:
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
OrderAmount DECIMAL(10, 2),
CHECK (OrderAmount > 0)
);
Integrity constraints ek database mein data quality aur consistency ko improve karte hain, aur
database management system in constraints ke through specified rules ko enforce karta hai.
[DBMS NOTES BY KHYATI]
UNIT – 2
Relational query languages
Relational algebra
Relational algebra ek theoretical query language hai jo relational databases ke design aur
manipulation ke liye use hota hai. Ye language mathematical expressions ka use karta hai jo
relations (tables) ke operations ko represent karte hain.
1. Select (σ): Select operation ka use kisi specific condition ke based par rows ko filter karne
ke liye hota hai. Jaise ki SQL mein WHERE clause ka use hota hai.
2. Project (π): Project operation se hum specific columns ko select karte hain. Ismein only
specified columns ko retain kiya jata hai.
3. Union (∪): Union operation se do relations ko combine kiya jata hai aur duplicate entries ko
remove kiya jata hai.
Example: R∪S
Yahaan R aur S ke common columns hone chahiye, aur ye operation un dono relations ko
combine karega.
4. Intersection (∩): Intersection operation se common entries ko retain kiya jata hai, matlab
woh entries jo dono relations mein common hain.
Example: R∩S
Yahaan R aur S ke common columns hone chahiye, aur ye operation un common entries ko
dikhayega.
Example: R-S
Is expression se R mein se woh entries nikali jaayengi jo S mein exist nahi karte.
[DBMS NOTES BY KHYATI]
Example:
Maan lo, ek relation hai R(Name, Age, Salary) aur humein woh employees chahiye jinki salary
50000 se zyada hai. TRC mein, ye express ho sakta hai:
{ t ∣ t∈ R ∧ t[Salary]>50000}
Iska matlab hai "wah set of tuples 't' jisme 't' relation R ka hissa hai aur 't[Salary]' 50000 se
zyada hai."
Example:
Agar hum wahi relation R(Name, Age, Salary) lete hain aur humein woh employees chahiye
jinki salary 50000 se zyada hai, toh DRC mein ye express ho sakta hai:
{Name∣∃Age,Salary(R(Name,Age,Salary)∧Salary>50000)}
Iska matlab hai "wah set of names jisme kuch aise Age aur Salary exist karte hain jisse R(Name,
Age, Salary) true hota hai aur Salary 50000 se zyada hai."
Domain Dependency
Domain dependency ka matlab hota hai ek relational database mein attributes ke beech ka
relation, jahaan ek attribute ke values doosre attribute ke values par depend karte hain, aur dono
attributes ek hi domain mein hote hain.
Example:
Maan lo, ek relation hai Employee(Name, EmployeeID, Department, Salary). Is relation mein
Department aur Salary ke beech ek domain dependency hoti hai. Kisi employee ki salary uske
department par depend karti hai. Jaise ki "Finance" department ke employees ki salary "IT"
department ke employees ki salary se alag hogi.
Significance:
Domain dependency ko samajhna ek normalized database design ke liye bahut zaroori hai. Ye
database ko efficient tareeke se organize karne mein madad karta hai aur redundancy ko avoid
karne mein help karta hai.
[DBMS NOTES BY KHYATI]
Data Dependency
Data dependency ka matlab hota hai database mein do data sets ke beech ka relation, jahaan ek
data set mein koi changes hone par doosre data set ko bhi asar hota hai.
1. Functional Dependency
Ye ek relation hai do attribute sets ke beech mein, jahaan ek attribute ka value doosre attribute
ka value uniquely determine karta hai.
Example: Ek relation Student(Name, RollNumber, Age) mein agar hum assume karein
ki RollNumber uniquely Name ko determine karta hai, toh yahaan functional
dependency hoti hai.
2. Multivalued Dependency
Ye ek relation hai do attribute sets ke beech mein, jahaan ek set of attributes doosre set ko
uniquely determine karta hai, aur ek tisra set hota hai jo pehle do sets ke independent hota hai.
Example: Ek relation Book(Author, Title, Genre) mein agar Author uniquely determine
karta hai Title aur Genre ko, aur Title aur Genre ek-doosre se independent hain, toh
yahaan multivalued dependency hoti hai.
3. Transitive Dependency
Ye ek relation hai jahaan ek attribute doosre attribute ko teesre attribute ke through determine
karta hai.
Example: Ek relation Classroom(Building, RoomNumber, Professor) mein agar
Building RoomNumber ko determine karta hai aur RoomNumber Professor ko
determine karta hai, toh yahaan transitive dependency hoti hai.
Significance:
Data dependency ko samajhna database normalization ke liye bahut zaroori hai. Ye process hoti
hai data ko organize karne ki, jisse redundancy aur dependency se bacha ja sake. Sahi tarah se
data dependency ko identify aur manage karna data integrity ko assure karta hai aur database
ko data modification operations ke dauran anomalies se bachata hai.
Armstrong's axioms
Armstrong's axioms woh kuch niyam hain jo ek relational database mein functional
dependencies ko define karte hain. Ye niyam William W. Armstrong ne propose kiye the aur
database normalization ke theory mein ek important role play karte hain. Yahan Armstrong's
axioms hinglish mein samjha ja raha hai:
1. Reflexivity Axiom:
- Agar Y X ka subset hai, toh X → Y true hai.
- Symbolically, agar X ⊇ Y hai, toh X → Y.
[DBMS NOTES BY KHYATI]
2. Augmentation Axiom:
- Agar X → Y true hai, toh wahi attribute dono sides mein add karne se
dependency preserve hoti hai.
- Symbolically, agar X → Y hai, toh XZ → YZ.
3. Transitivity Axiom:
- Agar X → Y aur Y → Z dono true hain, toh X → Z bhi true hai.
- Symbolically, agar X → Y aur Y → Z hai, toh X → Z.
Ye axioms hamein samajhne mein aur dusre functional dependencies ko derive karne mein
madad karte hain jo ek relational schema mein ho sakti hain. Ye database design ke
normalization process mein badi bhoomika nibhate hain.
Functional Dependencies
Functional dependency ek aisi rishta hai jo do attributes ke beech mein hota hai. Iska aam taur
par use hota hai primary key aur non-key attribute ke beech mein ek table mein.
X → Y
Functional Dependency (FD) mein, left side ko determinant kehte hain, aur right side ko
dependent kehte hain.
For example:
• Hamare paas ek employee table hai jismein kuch attributes hain: Emp_Id, Emp_Name,
aur Emp_Address.
• Yahaan, Emp_Id attribute Emp_Name attribute ko uniquely identify kar sakta hai kyun
ki agar hamein Emp_Id pata hai, toh hum keh sakte hain ki us associated employee ka
naam kya hai.
• Functional dependency ko likhne ka tareeka:
Emp_Id → Emp_Name
• Ham kah sakte hai ki Emp_Name functionally Emp_Id par depent hai.
Trivial Dependency:
Agar Y X ka subset hai, toh X→Y ko trivial mana jata hai. For example, A→A ek trivial
dependency hai.
Non-Trivial Dependency:
Agar Y X ka subset nahi hai, toh X→Y non-trivial hota hai. Jaise ki, agar X={A,B} aur Y={C},
toh X→Y non-trivial hai.
[DBMS NOTES BY KHYATI]
Normal forms
UNIT – 4
Transaction processing
Ek transaction ek program hai jo ek data processing ke logic unit ke roop mein, ek collection
ke database operations ko shamil karke execute hota hai. Transaction mein kiye jaane wale
operations mein database operations jaise insert, delete, update, ya data retrieve shaamil ho
sakte hain. Yeh ek atomic process hai jo ki puri tarah se execute hota hai ya fir bilkul bhi nahi
hota. Agar ek transaction mein sirf data retrieve hota hai aur koi data update nahi hota, toh use
read-only transaction kehte hain.
Transaction processing ek database management system (DBMS) ka mahatva purna hissa hai
jo data ki integrity aur consistency ko ensure karta hai.
For example, a data update operation can be divided into three tasks −
• read_item() − reads data item from storage to main memory.
• modify_item() − change value of item in the main memory.
• write_item() − write the modified value from main memory to storage.
Concurrency control
Concurrency control ek bahut mahatva purna hissa hai multiple users ke environments mein
transaction processing ka. Yeh ensure karta hai ki kai transactions ek sath execute ho sakti hain
bina ACID properties ko tutne ke.
1. Locking:
Transactions data items par lock hasil karte hain taki doosre transactions us data ko ek sath
access ya modify na kar sake.
2. Isolation Levels:
Alag-alag isolation levels jaise ki Read Uncommitted, Read Committed, Repeatable Read, aur
Serializable, define karte hain ki concurrent transactions ke beech mein dekhai jane wali aur
interaction ka star kya hoga.
3. Transaction Scheduling:
Scheduler transactions ko kis kram mein execute kiya jayega, yeh tay karta hai, consistency
aur isolation ko banaaye rakhne ke liye.
[DBMS NOTES BY KHYATI]
ACID property
ACID properties ek set hai jo transactions ke reliability aur consistency ko database
management system mein ensure karte hain.
1. Atomicity
Ek transaction ko atomic mana jata hai, arthath yeh ek akela, bhinnahin karya unit ke roop mein
vyavhar hota hai. Ya toh transaction ke andar ke saare operations poore hote hain, ya phir koi
bhi nahi hota. Agar koi bhi hissa transaction mein fail hota hai, toh puri transaction ko pehle ke
sthiti mein lauta diya jata hai, data consistency ko banaaye rakhne ke liye.
2. Consistency
Consistency property yeh ensure karta hai ki ek transaction database ko ek consistent sthiti se
doosre consistent sthiti tak le aaye. Transaction ke execution se pehle aur baad mein integrity
constraints ko poora karna zaroori hai.
3. Isolation
Isolation yeh ensure karta hai ki ek transaction ka execution doosre transactions se alag hota
hai. Halki-bhuliye kai transactions ek sath execute ho sakti hain, lekin unke parinam aise hone
chahiye jaise ki ve kisi kramik kram mein execute ho rahe hain. Isolation interference ko rokta
hai.
4. Durability
Durability yeh guarantee karta hai ki ek transaction jab commit ho jati hai, toh uske asar
database parmanant hote hain, system failures ke bawajood bhi. Jo parivartan committed
transaction dwara kiye gaye hain, ve tikte hain aur nahi ghat-te, sthayi data integrity ko ensure
karte hain.
Locking:
Locking ek aisi technique hai jisme hum locks ka istemaal karte hain taaki multiple transactions
ek hi samay mein kisi shared resource (jaise database records) ko access na kar sakein.
Locks Ke Types:
1. Shared Locks: Allow karte hain multiple transactions ko resource ko padhne mein,
lekin likhne mein sirf ek ko.
2. Exclusive Locks: Sirf ek hi transaction ko likhne ki permission dete hain, baaki ko
bilkul bhi nahi.
[DBMS NOTES BY KHYATI]
Lock Granularity:
• Coarse-Grained Locks: Pura table ya bada portion lock hota hai. Simple to implement,
lekin concurrency kam ho sakti hai.
• Fine-Grained Locks: Specific data items ko lock karte hain. Concurrency zyada hoti
hai, lekin complexity badh jaati hai.
Locking Protocols:
• Two-Phase Locking (2PL): Transactions locks acquire karte hain do phases mein - ek
growing phase mein aur ek shrinking phase mein. Ek baar lock release ho gaya, toh
naya lock acquire nahi ho sakta.
• Strict Two-Phase Locking (S2PL): Yeh 2PL ka ek variation hai, jisme unlock tab tak
nahi hota jab tak transaction commit point par nahi pahunch jaata.
Timestamp-Based Schedulers:
Timestamp-based concurrency control mein, har transaction ko ek unique timestamp assign
hota hai, jo uski start time ko represent karta hai. Isse transactions ko order mein rakh ke ensure
hota hai ki ve serializable tareeke se execute ho.
Database recovery
Database recovery ek critical aspect hai Database Management Systems (DBMS) mein, jo
catastrophic failures ya system crashes ke baad database ko restore karne ka process handle
karta hai. Iska main goal hai data consistency aur durability ko maintain karna, taki kisi bhi
data loss situation mein bhi database recover ho sake.
Database recovery do main components par based hota hai: logging aur checkpointing.
1. Logging:
2. Checkpointing:
[DBMS NOTES BY KHYATI]
Commit Analysis
Phase Phase
Undo Redo
Phase Phase
• Analysis Phase:
1. DBMS, last checkpoint se lekar crash tak ke logs ko analyze karta hai.
2. Transaction logs se recoverable transactions ko identify karta hai.
• Redo Phase:
1. Identified transactions ke actions ko redo karta hai from the log records.
2. Yeh ensure karta hai ki sabhi transactions ke effects dubara se database mein
apply ho jaayein, takki last consistent state restore ho sake.
• Undo Phase:
1. Jo transactions partially commit hokar crash huye the, unke actions ko undo
karta hai.
2. Is phase mein, incomplete transactions ke effects ko reverse karte huye database
ko last consistent state tak laaya jata hai.
• Commit Phase:
1. Finally, recovery process ke end mein, DBMS sabhi transactions ko commit
mark karta hai, jisse woh officially database mein reflect ho jaayein.
[DBMS NOTES BY KHYATI]
UNIT – 5
Database Security
• Authentication
Authentication ek process hai jisme user ko verify kiya jata hai, yani ki ye confirm kiya jata
hai ki user jo hai woh actual me wahi hai jo woh keh raha hai.
DBMS Me Kaise Kaam Karta Hai - Jab ek user DBMS mein login karta hai, toh
authentication check hoti hai. Yeh username-password pair ya phir koi aur authentication
method ka use karke verify ki jati hai ki user authorized hai ya nahi.
• Authorization
Authorization ek process hai jisme decide kiya jata hai ki ek authenticated user ko kis level ki
permissions aur rights milegi.
DBMS Me Kaise Kaam Karta Hai - Jab user authenticate ho jata hai, toh DBMS decide karta
hai ki user ko kya access aur kya operations perform karne ki permissions di jayengi. For
example, kuch users sirf read access ke liye authorize hote hain, jabki kuch ko write ya delete
operations ke liye bhi authorization milti hai.
• Access Control
Access control ka mtlb hota hai control karna ki kaun kis resource tak pahunch sakta hai aur
kya operations perform kar sakta hai.
DBMS Me Kaise Kaam Karta Hai - Access control policies define ki jati hain jo decide karte
hain ki kaun kis data ko access kar sakta hai aur kya modifications kar sakta hai. Isme role-
based access control bhi include hota hai, jisme roles assign kiye jaate hain aur un roles ke
basis par hi access control decisions li jati hain.
DAC model mein, access control decisions users ke discretion (manoranjak) par depend karte
hain. Iska mtlb hai ki data owner ko control hota hai ki kaun kis data ko access karega aur kya
operations perform karega.
DBMS Me Kaise Kaam Karta Hai- Har user ko ek set of permissions di jati hai, aur data
owner decide karta hai ki un permissions ke basis par kaun kis data ko access karega. For
example, ek user ko sirf read access ho sakti hai, jabki doosre ko write ya delete access bhi ho
sakti hai.
DBMS Me Kaise Kaam Karta Hai - Har user ko ek security label diya jata hai, aur data
objects bhi in labels ke sath tag kiye jaate hain. Access tabhi allowed hota hai jab user ka label
data object ke label se match karta hai. Isme data owner ka discretion nahi hota, balki
predefined rules follow hote hain.
DBMS Me Kaise Kaam Karta Hai - Users ko roles assign kiye jaate hain, aur phir un roles
ke basis par hi access control decisions li jati hain. For example, ek organization mein
"Manager" role ko write access diya ja sakta hai, jabki "Employee" role ko sirf read access diya
ja sakta hai.
Summary
• DAC: Users ke discretion par depend karta hai, jisme data owners control karte hain.
• MAC: Predefined security policies par depend karta hai, jisme data labels aur
predefined rules use hote hain.
• RBAC: Roles ke basis par defined hota hai, jisme users ko specific roles assign kiye
jaate hain aur un roles ke sath associated permissions hoti hain.
Intrusion Detection
Intrusion Detection ka mtlb hota hai kisi bhi unauthorized access, attacks, ya abnormal
activities ko identify karna aur uske against measures lene ka process. Yeh ek crucial part hai
information security ka, jo systems ko protect karta hai against malicious activities. Intrusion
Detection System (IDS) ismein madad karta hai.
Working
Monitoring
Analysis
Alerting
Response
SQL injection
SQL injection ek tarah ka security vulnerability hai jisme attacker user input ka galat istemal
karke database ke query ko manipulate kar leta hai. Isse unauthorized access, data badalna ya
dusre nuksan karne ke chances badh jaate hain. Ye web applications ke liye ek common aur
serious threat hai jo SQL queries ka istemal karte hain.
Ex.
SELECT * FROM users WHERE username = 'input_username' AND password = 'input_password';
SELECT * FROM users WHERE username = '' OR '1'='1'; --' AND password = '';
• Yahan `--` SQL mein ek comment hota hai, isse baaki ka kuch bhi execute nahi hoga.
Isse query hamesha true ho jayegi (`'1'='1'`), aur attacker ko unauthorized access mil
jaayega.
[DBMS NOTES BY KHYATI]
Data warehousing
Data warehousing ek process hai jisme hum data ko collect, store, aur manage karte hain ek
centralized location mein, jo hum kehte hain data warehouse. Iska main aim hota hai ki hum
business intelligence aur decision-making ke liye data ko ek jagah par lekar aayein. Chaliye
isko aur detail mein samajhte hain:
3. Data Warehouse:
Data warehouse ek centralized storage hai jisme data organized tareeke se rakha jaata hai. Yeh
query aur analysis ke liye design hota hai, jisse users complex queries run karke reports
generate kar sakein.
4. Metadata:
Metadata hota hai data warehouse ke baare mein information, jaise ki data ka source, meaning,
format, aur relationships. Yeh users ko data samajhne aur navigate karne mein madad karta hai.
Key Concepts:
1. Subject-Oriented:
Data warehousing specific subjects ya business areas par focus karta hai, jaise ki sales, finance,
ya marketing. Isse data ka comprehensive view milta hai.
2. Integrated:
Data warehousing alag-alag sources se aane wala data ek consistent format mein integrate karta
hai. Isse organization ke andar data ka unified view milta hai.
[DBMS NOTES BY KHYATI]
3. Time-Variant:
Data warehousing historical data capture karta hai aur time-based analysis ko support karta hai.
Isse users ko changes aur trends ko track karne mein madad milti hai.
4. Non-Volatile:
Jab data warehouse mein data load ho jaata hai, woh read-only ho jaata hai. Is non-volatile
nature se yeh ensure hota hai ki historical data unchanged rahe aur analysis ke liye stable
environment ho.
Data mining
Data mining ek process hai jisme hum large datasets se patterns, relationships, aur useful
information extract karte hain. Iska main aim hota hai hidden insights aur knowledge ko
discover karna, jo traditional database analysis ke through possible nahi hota. Chaliye isko
detail mein samajhte hain:
2. Types of Patterns:
• Association Rule Mining: Identifying associations or relationships between different
variables in the dataset. For example, people who buy product X are likely to buy
product Y as well.
• Classification: Predicting the category or class of a new item based on past
observations. For instance, predicting whether an email is spam or not.
• Clustering: Grouping similar data points together based on certain features or
characteristics.
• Regression Analysis: Predicting numerical values based on historical data.
3. Data Exploration:
Data mining allows for exploration of data to discover trends, anomalies, and interesting
patterns that might not be immediately apparent.
4. Algorithm Usage:
Various algorithms are used in data mining, such as decision trees, neural networks, clustering
algorithms, and association rule algorithms, depending on the type of analysis required.
[DBMS NOTES BY KHYATI]
5. Data Preprocessing:
Data preprocessing is an essential step in data mining, involving cleaning, transforming, and
organizing the data to ensure accurate and meaningful results.
2. Healthcare:
Data mining helps in predicting disease outbreaks, identifying patient trends, and improving
treatment outcomes.
3. Finance:
Fraud detection, credit scoring, and market trend analysis are common applications of data
mining in the financial sector.
4. Telecommunications:
Analyzing call records and customer data helps in improving service quality and identifying
potential issues.
5. Marketing:
Targeted advertising, customer segmentation, and market basket analysis are common uses of
data mining in marketing.
2. Improved Decision-Making:
By uncovering hidden patterns and relationships, data mining provides valuable insights that
can aid in better decision-making.
3. Customer Retention:
Businesses use data mining to understand customer behavior, preferences, and satisfaction,
which helps in customer retention strategies.
4. Risk Management:
In industries like finance, data mining is crucial for identifying and managing risks associated
with various financial transactions.
5. Operational Efficiency:
Data mining helps in optimizing processes, improving efficiency, and reducing costs by
identifying areas for improvement.
[DBMS NOTES BY KHYATI]
2. Overfitting:
Overfitting occurs when a model is too complex and fits the training data too closely, resulting
in poor performance on new, unseen data.
3. Interpretability:
Some complex data mining models may be difficult to interpret, making it challenging for users
to understand and trust the results.
4. Privacy Concerns:
The use of personal data in data mining raises privacy concerns. Striking a balance between
data utilization and privacy protection is crucial.