0% found this document useful (0 votes)
4 views16 pages

Unit 1

The document compares Database Management Systems (DBMS) and File Systems, highlighting differences in data management, redundancy, security, integrity, multi-user support, query support, backup, recovery, and scalability. It also explains the three-level architecture of databases, detailing internal, conceptual, and external levels, along with their advantages. Additionally, it covers various data models, database languages, and the overall structure of databases, emphasizing the importance of understanding these concepts for effective database management.

Uploaded by

officialtaeliens
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

Unit 1

The document compares Database Management Systems (DBMS) and File Systems, highlighting differences in data management, redundancy, security, integrity, multi-user support, query support, backup, recovery, and scalability. It also explains the three-level architecture of databases, detailing internal, conceptual, and external levels, along with their advantages. Additionally, it covers various data models, database languages, and the overall structure of databases, emphasizing the importance of understanding these concepts for effective database management.

Uploaded by

officialtaeliens
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Unit 1

Question 1. DBMS vs. File System


DBMS (Database Management System) aur File System ke beech ka difference samajhna zaroori hai:

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.

2. Data Redundancy (Duplicate Data):

 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:

 File System: Ek file ek hi user ke liye efficiently accessible hoti hai.

 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:

 File System: Backup aur recovery manual process hai.

 DBMS: Automatic backup aur recovery features provide karta hai.

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:

 File System: Aapke computer ki folders aur text files.

 DBMS: Online platforms jaise Amazon, Flipkart, ya banking systems, jahan har user ka data systematically store
hota hai.

Short Conclusion:

 File System: Chhoti aur simple applications ke liye theek hai.

 DBMS: Large-scale applications aur multi-user systems ke liye best hai.

Question 2. Three-Level Architecture

Three Levels of Architecture

1. Internal Level (Physical Level)

o Yeh kya hai?


Data ka actual storage kaise ho raha hai, yeh describe karta hai. Matlab, data hard disk ya SSD pe kis
format me save ho raha hai, yeh level handle karta hai.

o Features:

 Data ki physical storage details define karta hai.

 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 Yeh kya hai?


Pura database ka logical structure represent karta hai. Is level pe hum sirf data ke types, relationships,
aur constraints ke baare mein baat karte hain, bina physical details ke.

o Features:

 Pura database ka ek overall view deta hai.

 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.

3. External Level (View Level)

o Yeh kya hai?


Users ko jo data dikhai deta hai, uska representation karta hai. Har user ke liye ek customized view ho
sakta hai, jo unke kaam ke hisaab se filtered hota hai.

o Features:

 Data security aur privacy ensure karta hai.

 Users ko sirf wahi data dikhata hai jo unke liye relevant hai.

o Example:

 Ek student ko sirf uska attendance aur marks dikhaye jaate hain.

 Ek teacher ko sab students ka data dikhai de sakta hai.

Diagram Representation

External Level (User Views)

Conceptual Level (Logical View)

Internal Level (Physical Storage)

Advantages of Three-Level Architecture

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

Question 3. Data Models

Data Models DBMS ka ek fundamental concept hai jo define karta hai ki database ke data ko kaise organize,
store, aur access kiya jayega:

Data Models Kya Hai?


Data Models woh framework hai jo batata hai ki data ko database me kaise represent karenge. Iska main focus
hota hai:
 Data ka structure
 Relationships
 Constraints
 Operations

Types of Data Models


1. Hierarchical Data Model
o Kya hai?
Is model me data ek tree-like structure me organize hota hai, jisme parent-child relationship hoti hai.
o Key Features:
 Ek parent ke multiple children ho sakte hain, but ek child ka sirf ek parent hota hai.
 Data hierarchical form me store hota hai.
o Example:
Ek company structure jisme CEO ke neeche managers, aur managers ke neeche employees hote hain.
o Diagram Representation:
yaml
Copy code
CEO
|
Manager1
|
Employee1

2. Network Data Model


o Kya hai?
Is model me data ko graph structure me represent kiya jata hai, jisme parent-child relationships ke saath
many-to-many relationships bhi handle hote hain.
o Key Features:
 Nodes (data entities) aur edges (relationships) ka use karta hai.
 Zyada flexible hota hai compared to hierarchical model.
o Example:
Ek library system jisme ek book multiple authors se linked ho sakti hai, aur ek author multiple books likh
sakta hai.

3. Relational Data Model


o Kya hai?
Is model me data ko tables (relations) ke form me store kiya jata hai, jisme rows (tuples) aur columns
(attributes) hote hain.
o Key Features:
 Data ko tabular format me store karta hai.
 SQL queries ka use karke data access aur manipulate karte hain.
o Example:
Student table:
css
Copy code
Roll_No | Name | Course
101 | Aman | B.Tech
102 | Priya | MBA

4. Entity-Relationship (E-R) Model


o Kya hai?
Yeh model entities (objects) aur unke beech ke relationships ko represent karta hai. Mostly, database
designing ke liye use hota hai.
o Key Features:
 Graphical representation ka use karta hai.
 Entities ke attributes aur relationships ko detail me explain karta hai.
o Example:
Ek E-R diagram me "Student" aur "Course" entities ko "Enrolls In" relationship se link karna.

5. Object-Oriented Data Model


o Kya hai?
Is model me data ko objects ke form me represent kiya jata hai, jo object-oriented programming ka
concept follow karta hai.
o Key Features:
 Objects, classes, aur inheritance ka use karta hai.
 Complex data aur behaviors ko store aur manage kar sakta hai.
o Example:
Ek car rental system jisme "Car" ek object hai, aur uske attributes jaise model, year, aur price hote hain.
Comparison of Data Models

Model Structure Key Feature Use Case

Hierarchical Tree Parent-child relationship Company hierarchy

Many-to-many
Network Graph Library system
relationships

Tabular data Banking and e-commerce


Relational Table
representation databases

Graphical
E-R Database designing Initial database design phase
diagram

Object- Complex data with Multimedia and real-time


Objects
Oriented behaviors systems

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.

Question 4. Database Languages in DBMS

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:

Database Languages Kya Hai?


Database languages ka use database ko create karne, manage karne, aur manipulate karne ke liye hota hai. Yeh
languages database ke andar data ko access karne aur uspar operations perform karne ki permission deti hain.

Types of Database Languages


1. Data Definition Language (DDL)
o Kya hai?
DDL ka use database ke structure ko define karne ke liye hota hai, jaise tables, schemas, aur indexes
create karna.
o Key Commands:
 CREATE: Nayi table ya database banane ke liye.
Example:
Sql Code
CREATE TABLE Student (
Roll_No INT,
Name VARCHAR(50),
Course VARCHAR(30)
);
 ALTER: Existing structure ko modify karne ke liye.
Example:

Sql Code
ALTER TABLE Student ADD Age INT;
 DROP: Table ya database ko delete karne ke liye.
Example:
Sql Code
DROP TABLE Student;

2. Data Manipulation Language (DML)


o Kya hai?
DML ka use data ko insert, update, delete, aur retrieve karne ke liye hota hai.
o Key Commands:
 INSERT: Table me naya data add karne ke liye.
Example:
Sql Code
INSERT INTO Student (Roll_No, Name, Course) VALUES (101, 'Aman', 'B.Tech');
 UPDATE: Existing data ko modify karne ke liye.
Example:
Sql Code
UPDATE Student SET Name = 'Priya' WHERE Roll_No = 101;
 DELETE: Data ko delete karne ke liye.
Example:
Sql Code
DELETE FROM Student WHERE Roll_No = 101;
 SELECT: Data ko retrieve karne ke liye.
Example:
Sql Code
SELECT * FROM Student;

3. Data Control Language (DCL)


o Kya hai?
DCL ka use database ke access aur permissions ko control karne ke liye hota hai.
o Key Commands:
 GRANT: User ko permission dene ke liye.
Example:
Sql Code
GRANT SELECT ON Student TO User1;
 REVOKE: User ki permission wapas lene ke liye.
Example:
Sql Code
REVOKE SELECT ON Student FROM User1;

4. Transaction Control Language (TCL)


o Kya hai?
TCL ka use transactions ko manage karne ke liye hota hai, jisse data consistency aur integrity ensure hoti
hai.
oKey Commands:
 COMMIT: Transaction ke changes ko permanently save karna.
Example:
Sql code
COMMIT;
 ROLLBACK: Transaction ke changes ko undo karna.
Example:
Sql code
ROLLBACK;
 SAVEPOINT: Transaction ke andar ek point create karna jaha se rollback ho sake.
Example:
Sql code
SAVEPOINT Save1;

5. Query Language (SQL)


o Kya hai?
Structured Query Language (SQL) ek standard language hai jo relational databases ke saath interact
karne ke liye use hoti hai.
o Example Query:
Sql code
SELECT Name, Course FROM Student WHERE Roll_No = 101;

Short Summary Table

Type Purpose Example Command

DDL Structure define karna CREATE, ALTER, DROP

DML Data manipulate karna INSERT, UPDATE, DELETE, SELECT

DCL Permissions control karna GRANT, REVOKE

TCL Transactions manage karna COMMIT, ROLLBACK, SAVEPOINT

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.

Question 5. Overall Database Structure

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:

Database Structure Kya Hai?


Database structure ka matlab hai database ke andar data aur usse related components ka arrangement. Isme
logical aur physical levels par data ka organization samajhna hota hai.
Overall Structure ke Key Components
1. Data
o Database ka main part data hota hai. Data ko systematically tables, rows, aur columns ke form me store
kiya jata hai.
o Example: Student table:
o Roll_No | Name | Course
o 101 | Aman | B.Tech
o 102 | Priya | MBA

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)

4. Tables and Relationships


o Data ko tables ke form me store kiya jata hai. Har table ke andar rows (tuples) aur columns (attributes)
hote hain.
o Tables ke beech relationships banaye jate hain:
 One-to-One: Ek student ka ek unique ID card.
 One-to-Many: Ek teacher multiple students ko padha raha hai.
 Many-to-Many: Ek student multiple courses le raha hai, aur ek course multiple students ke liye
hai.

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.

Question 6. Keys in DBMS

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.

Short Summary Table

Key Type Purpose Example

Primary Key Uniquely identify karta hai (No NULL, No Duplicates) Roll_No

Candidate Key Possible primary keys Roll_No, Email

Uniquely identify karta hai (Extra attributes ho sakte


Super Key {Roll_No, Name}
hain)

Course_ID in Student
Foreign Key Table relationships maintain karta hai
Table

Composite Key Multiple attributes ka combination {Order_ID, Product_ID}

Alternate Key Non-primary candidate key Email

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.

Question 7. Reduction of an ER Diagrams to Table

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:

ER Diagram Ko Table Me Convert Kyon Karte Hain?


ER diagram ek graphical representation hai jo entities, attributes, aur relationships ko dikhata hai. Lekin,
database implementation ke liye hume ise relational tables me convert karna hota hai. Yeh process ensure karta
hai ki database logical aur practical dono levels pe effectively work kare.

Steps to Reduce ER Diagram to Tables

1. Entity Ko Table Me Convert Karna


 Kya hai?
Har entity ko ek table me convert kiya jata hai. Table ke columns us entity ke attributes ko represent karte hain.
 Example:
Entity: Student
Attributes: Roll_No, Name, Course
Table:
Code:
Student
-----------------------
Roll_No | Name | Course

2. Primary Key Define Karna


 Har table me ek Primary Key define karna zaroori hota hai jo us table ki rows ko uniquely identify kare.
 Example:
Table Student me Roll_No primary key banegi.

3. Weak Entity Ko Table Me Convert Karna


 Kya hai?
Weak entity wo hoti hai jo apni identification ke liye kisi strong entity par depend karti hai.
 Steps:
o Weak entity ke attributes ko ek table me convert karein.
o Strong entity ka primary key foreign key ke form me add karein.
 Example:
Weak Entity: Dependent
Strong Entity: Employee
Sql code
Employee Table
------------------------
Emp_ID (PK) | Name
Dependent Table
-----------------------------------
Dep_ID | Name | Emp_ID (FK)

4. Relationships Ko Table Me Convert Karna


 Kya hai?
ER diagram me relationships ko bhi tables me convert karna hota hai, especially jab relationship ke apne
attributes ho.

 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)

5. Multi-Valued Attributes Ko Handle Karna


 Multi-valued attributes ke liye ek alag table banate hain.
 Example:
Entity: Employee
Attribute: Phone_Numbers (multi-valued)
Code:
Employee Table
-----------------
Emp_ID (PK) | Name

Employee_Phone Table
----------------------------
Emp_ID (FK) | Phone_Number

6. Composite Attributes Ko Simplify Karna


 Composite attributes ko unke sub-attributes me tod kar alag columns banate hain.
 Example:
Attribute: Full_Name (composite of First_Name aur Last_Name)
Code:
Employee Table
----------------------
Emp_ID (PK) | First_Name | Last_Name

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.

You might also like