Unit 1
Unit 1
1. Data Management:
File System: Data ko alag-alag files me store karta hai. Har file ka apna format hota hai, aur un files ko manually
manage karna padta hai.
DBMS: Data ko ek centralized system me store karta hai, jo better organization aur easy access provide karta hai.
File System: Same data kai jagah repeat ho sakta hai, jisse storage waste hoti hai aur consistency issues hote
hain.
DBMS: Data redundancy ko minimize karta hai by storing data in a structured way using tables and relationships.
3. Data Security:
File System: Basic security hoti hai, jaise password-protected files. Lekin kisi file ko unauthorized access se
protect karna mushkil ho sakta hai.
DBMS: Advanced security features provide karta hai, jaise user authentication aur access control.
4. Data Integrity:
File System: Data consistency ensure karna mushkil hota hai, especially jab multiple users data ko access karte
hain.
DBMS: Constraints aur rules ka use karke data integrity ensure karta hai, jaise primary keys aur foreign keys.
5. Multi-user Support:
DBMS: Multiple users ek hi data ko simultaneously access kar sakte hain without conflicts.
6. Query Support:
File System: Data access karne ke liye manual coding karni padti hai.
DBMS: SQL (Structured Query Language) ka use karke data easily retrieve kiya ja sakta hai.
7. Backup and Recovery:
8. Scalability:
File System: Large amount of data handle karna mushkil ho jata hai.
DBMS: Zyada data efficiently handle kar sakta hai, aur growth ke liye scalable hota hai.
Real-life Example:
DBMS: Online platforms jaise Amazon, Flipkart, ya banking systems, jahan har user ka data systematically store
hota hai.
Short Conclusion:
o Features:
Performance optimization ke liye storage techniques decide karta hai, jaise indexing ya hashing.
o Example:
Ek table ke rows aur columns ko memory blocks me kaise store kiya gaya hai, yeh is level pe define hota
hai.
2. Conceptual Level (Logical Level)
o Features:
Independent hota hai internal level se. Agar storage method change ho jaye, toh is level pe koi
impact nahi hota.
o Example:
"Student" table me Roll_No, Name, aur Course fields hain, aur Roll_No primary key hai. Yeh sab
conceptual level pe define hota hai.
o Features:
Users ko sirf wahi data dikhata hai jo unke liye relevant hai.
o Example:
Diagram Representation
1. Data Abstraction:
o Users ko sirf unka required data dikhaya jata hai, baaki complexities hide ki jaati hain.
2. Data Independence:
o Physical aur logical data ke changes ek dusre ko directly impact nahi karte.
3. Data Security:
o Har user ko customized view milta hai, jo unauthorized access ko prevent karta hai.
Short Conclusion
Three-Level Architecture ek systematic approach hai jo data ko alag-alag layers me divide karta hai. Isse data ko manage
karna easy hota hai, aur users aur developers ke beech ka complexity reduce hoti hai
Data Models DBMS ka ek fundamental concept hai jo define karta hai ki database ke data ko kaise organize,
store, aur access kiya jayega:
Many-to-many
Network Graph Library system
relationships
Graphical
E-R Database designing Initial database design phase
diagram
Short Conclusion
Data Models database ke structure aur usage ko define karte hain. Exam ke liye, har model ka diagram aur ek
real-life example zaroor yaad karein. Relational model aur E-R model pe zyada focus karein, kyunki yeh sabse
zyada practical hain.
Database Languages DBMS ka ek important concept hai jo batata hai ki database ke saath interact karne ke liye
kaun kaunsi languages use hoti hain:
Sql Code
ALTER TABLE Student ADD Age INT;
DROP: Table ya database ko delete karne ke liye.
Example:
Sql Code
DROP TABLE Student;
Short Conclusion
Database languages har database operation ke liye alag-alag commands provide karti hain. DDL aur DML sabse
zyada use hote hain, toh unko achhe se yaad karein. SQL queries ke example likhne ki practice karein taaki exam
me confidently likh sakein.
Overall Database Structure DBMS ka ek basic concept hai jo define karta hai ki database ke different components
aur levels kaise organize aur interact karte hain. AKTU 5th semester ke BCS501 syllabus ke liye, is topic ka achhe
se samajhna zaroori hai. Chaliye ise simple hinglish mein samajhte hain:
2. Database Schema
o Kya hai?
Database ka blueprint ya structure hota hai jo define karta hai ki tables, relationships, aur constraints
kaise organize honge.
o Types:
Physical Schema: Data ka actual storage kaise ho raha hai.
Logical Schema: Data ka logical design aur relationships.
View Schema: Users ke liye customized data views.
3. Three-Level Architecture
o Database structure ko Three-Level Architecture ke through samajha jata hai:
Internal Level: Physical storage details.
Conceptual Level: Overall logical structure.
External Level: User-specific data views.
o Diagram Representation:
o External Level (User Views)
o ↑
o Conceptual Level (Logical Design)
o ↑
o Internal Level (Physical Storage)
5. Constraints
o Constraints ka use database me data consistency aur integrity ensure karne ke liye hota hai.
o Common Constraints:
Primary Key: Har row ka unique identifier.
Foreign Key: Ek table ke data ko dusre table ke saath relate karta hai.
Not Null: Column me null values allowed nahi hain.
Unique: Har value unique honi chahiye.
6. Indexes
o Kya hai?
Indexes ka use fast data retrieval ke liye hota hai.
o Example:
Agar ek table me 1 lakh rows hain aur aapko Roll_No = 101 search karna hai, toh index query execution
fast karega.
7. Views
o Views ek virtual table hai jo original data ka customized representation dikhata hai.
o Use Case:
Ek user ko sirf specific columns dikhane ke liye view ka use hota hai.
8. Transactions
o Kya hai?
Transaction ek group of operations hai jo ek consistent state me database ko rakhta hai.
o Properties (ACID):
Atomicity: Ya toh saari operations complete hongi ya koi nahi.
Consistency: Data valid state me rehna chahiye.
Isolation: Transactions independent honi chahiye.
Durability: Transaction ke baad changes permanent hone chahiye.
Diagram Representation
Database Structure:
------------------------------
| Tables (Data Storage) |
| Relationships (Links) |
| Schema (Design Blueprint) |
| Constraints (Rules) |
| Indexes (Search Optimization)|
| Views (Custom Representation)|
| Transactions (Operations) |
------------------------------
Short Summary
1. Database ke main parts: Data, schema, relationships, aur views.
2. Organized structure: Three-level architecture (Internal, Conceptual, External).
3. ACID properties aur constraints ensure karte hain ki data secure aur consistent rahe.
Conclusion:
Overall Database Structure samajhne ke liye tables, relationships, aur architecture pe focus karein. Diagram aur
examples zaroor banayein exam me zyada clarity ke liye.
Keys in DBMS ek important topic hai jo database tables me data ki uniqueness aur relationships maintain karne
ke liye use hota hai. AKTU 5th semester ke BCS501 syllabus ke liye, keys ka concept clear hona zaroori hai.
Chaliye ise simple hinglish mein samajhte hain:
Keys Kya Hai?
Keys ek ya ek se zyada attributes (columns) ka group hoti hain, jo database table ke records ko uniquely identify
karte hain. Keys ka use data consistency aur integrity maintain karne ke liye hota hai.
Types of Keys
1. Primary Key
Kya hai?
Primary key ek table me ek unique identifier hota hai jo har row ko uniquely identify karta hai.
Features:
o Duplicate values allowed nahi hain.
o NULL values allowed nahi hain.
Example:
Student table me Roll_No primary key ho sakta hai:
css
Copy code
Roll_No | Name | Course
101 | Aman | B.Tech
102 | Priya | MBA
2. Candidate Key
Kya hai?
Candidate key ek table me aise attributes ka set hota hai jo uniquely identify kar sakte hain. Ek table me multiple
candidate keys ho sakti hain, lekin unme se ek ko primary key choose kiya jata hai.
Example:
Student table me Roll_No aur Email dono candidate keys ho sakti hain, kyunki dono unique hain.
3. Super Key
Kya hai?
Super key ek table ka aisa attribute ya attributes ka group hai jo records ko uniquely identify kar sakta hai.
Difference from Candidate Key:
Super key me unnecessary attributes ho sakte hain, lekin candidate key minimal hoti hai.
Example:
Roll_No alone is a candidate key, but {Roll_No, Name} is a super key.
4. Foreign Key
Kya hai?
Foreign key ek table ke attribute ko dusre table ke primary key ke saath relate karne ke liye use hoti hai.
Features:
o Table relationships define karta hai.
o Parent-child relationship maintain karta hai.
Example:
Ek Student aur Course table:
Code:
Student Table:
Roll_No | Name | Course_ID
101 | Aman | C01
Course Table:
Course_ID | Course_Name
C01 | B.Tech
Yaha Course_ID foreign key hai jo Course table ke primary key se related hai.
5. Composite Key
Kya hai?
Composite key do ya zyada attributes ka combination hota hai jo milke records ko uniquely identify karte hain.
Example:
Ek Order table me Order_ID aur Product_ID ka combination composite key ho sakta hai:
Copy:
Order_ID | Product_ID | Quantity
1 | 101 |5
1 | 102 |2
6. Alternate Key
Kya hai?
Candidate keys me se jo primary key nahi bani, usse alternate key kehte hain.
Example:
Agar Roll_No primary key hai, toh Email alternate key hogi.
7. Unique Key
Kya hai?
Unique key ek aisa attribute hota hai jo table ke records ko uniquely identify karta hai, lekin isme NULL value ek
baar allowed hoti hai.
Example:
Phone_Number column ek unique key ho sakta hai.
Primary Key Uniquely identify karta hai (No NULL, No Duplicates) Roll_No
Course_ID in Student
Foreign Key Table relationships maintain karta hai
Table
Unique Key Unique value ensure karta hai (1 NULL allowed) Phone_Number
Short Conclusion
Keys database me data ki uniqueness aur relationships ensure karti hain. Primary key aur foreign key exam ke
liye sabse important hain. Diagram aur real-life examples zaroor banayein aur practice karein taaki concepts
clear ho.
ER Diagram ka Reduction to Tables DBMS ka ek important process hai jo Entity-Relationship (ER) diagram ko
relational database tables me convert karta hai:
Types of Relationships:
a) One-to-One (1:1):
o Dono entities ke primary keys me se ek ko dusri table ka foreign key bana dete hain.
o Example:
Person aur Passport:
Sql Code:
Person Table
------------------
Person_ID (PK) | Name
Passport Table
------------------
Passport_ID (PK) | Person_ID (FK)
b) One-to-Many (1:N):
o "Many" side ki table me "One" side ki table ka primary key foreign key ke form me add karte hain.
o Example:
Teacher aur Student:
Sql code:
Teacher Table
-----------------
Teacher_ID (PK) | Name
Student Table
-----------------
Student_ID (PK) | Teacher_ID (FK)
c) Many-to-Many (M:N):
o Ek separate table banate hain jo dono entities ke primary keys ko apne attributes ke form me rakhta hai.
o Example:
Student aur Course:
Sql code:
Student Table
-----------------
Roll_No (PK) | Name
Course Table
-----------------
Course_ID (PK) | Title
Student_Course Table
------------------------------
Roll_No (FK) | Course_ID (FK)
Employee_Phone Table
----------------------------
Emp_ID (FK) | Phone_Number
Short Example
ER Diagram:
Entities: Student, Course
Relationship: Enrolls (M:N)
Attributes:
o Student: Roll_No, Name
o Course: Course_ID, Course_Name
o Enrolls: Grade
Conversion to Tables:
1. Student Table:
Code:
Roll_No (PK) | Name
2. Course Table:
Code:
Course_ID (PK) | Course_Name
3. Enrolls Table (for Relationship):
Code:
Roll_No (FK) | Course_ID (FK) | Grade
Short Summary
1. Har entity ko ek table me convert karein.
2. Weak entities aur relationships ke liye foreign keys ka use karein.
3. Multi-valued aur composite attributes ko simplify karein.
4. Relationships (1:1, 1:N, M:N) ko unke rules ke hisaab se handle karein.
Conclusion:
ER diagram se tables me conversion logical designing ko physical implementation me transform karne ka process
hai. Exam ke liye examples aur diagrams practice karna zaroori hai.