BCA / B.Tech 14 min read

File Organization In Hindi

RK

लेखक Ratan Kumawat · संस्थापक, NotesMedia

प्रकाशित:

त्वरित सारांश और मुख्य बिंदु

  • • विषय फोकस: DBMS Notes in Hindi | डीबीएमएस नोट्स (BCA / B.Tech Syllabus)
  • • मुख्य विषय: File Organization In Hindi - General Topics
  • • अवलोकन: Quick Answer: DBMS में File Organization वह तरीका है जिससे records को physical storage (hard disk या SSD) पर blocks के रूप में arrange और store किया जा...
  • • मुख्य अवधारणाएं: File organization, Sequential indexed hashed B tree Hindi, File structures,
Quick Answer: DBMS में File Organization वह तरीका है जिससे records को physical storage (hard disk या SSD) पर blocks के रूप में arrange और store किया जाता है, ताकि data को कम से कम समय और कम disk I/O में access (read, search, insert, update) किया जा सके। Related fields मिलकर record बनाते हैं, records के group को file कहते हैं, और related files के collection को Database कहा जाता है। DBMS में मुख्य रूप से चार file organization techniques इस्तेमाल होती हैं: Sequential, Heap (Unordered), Hash (Direct), और Indexed File Organization।

File Organization in DBMS क्या है? (File Organization Meaning)

DBMS में data logically tables (relations) के रूप में दिखता है, लेकिन physically वह hard disk पर 0 और 1 के binary format में blocks के अंदर save होता है। Hard disk से RAM में data पढ़ना सबसे धीमा काम होता है। इसी वजह से यह तय करना ज़रूरी है कि records को disk blocks में किस order में रखा जाए, ताकि search करते समय disk access कम से कम हो।

जिस systematic तरीके से records को file के अंदर store, map और access किया जाता है, उसे File Organization कहते हैं। अगर आप सही file organization चुनते हैं, तो search query millisecond में execute हो जाती है। गलत organization चुनने पर पूरे disk को scan करना पड़ता है, जिससे system बहुत slow हो जाता है। File system और DBMS का संबंध समझने के लिए यह note पढ़ें: DBMS और File System में अंतर.

Advertisement

Data Hierarchy: Field, Record, File और Database

File organization को अच्छी तरह समझने के लिए data की hierarchy जानना ज़रूरी है:

  • Bit: Data की सबसे छोटी unit (0 या 1)।
  • Byte (Character): 8 bits का group, जैसे कोई letter 'A' या digit '5'।
  • Field: Characters का group जो किसी एक attribute को दिखाता है, जैसे Roll_No, Name, Marks।
  • Record: Related fields का collection जो किसी एक entity की पूरी जानकारी देता है, जैसे एक student का पूरा record।
  • File: एक जैसे format वाले related records का collection।
  • Database: कई related files और tables का organized collection।

A Collection of Files is Called What?

Exams और interview में यह basic सवाल बार-बार पूछा जाता है कि "a collection of files is called" या "group of files is called":

  • DBMS के context में: Related files के organized collection को Database कहा जाता है। Data को centralized organize करने का concept यहाँ समझें: Database क्या है.
  • Operating System के context में: Files के group को hold करने वाली structure को Directory या Folder कहते हैं।
  • Storage/Backup के context में: एक साथ रखी गई old files के group को Archive कहा जाता है।

File Organization के मुख्य Objectives (उद्देश्य)

DBMS में file organization चुनते समय system designers इन 5 goals का ध्यान रखते हैं:

  1. Fast Data Retrieval: User की query का result कम से कम समय में screen पर दिखाना।
  2. Minimum Disk I/O: Hard disk से data block पढ़ने में सबसे ज़्यादा time लगता है। अच्छा file organization disk read/write operations की संख्या घटाता है।
  3. Storage का Efficient Use: Hard disk पर फालतू खाली जगह (internal/external fragmentation) न छूटे।
  4. Easy Modification: नए record insert करना, पुराना delete करना या update करना आसान हो और पूरी file को बार-बार rearrange न करना पड़े।
  5. Security और Reliability: Disk crash होने पर data recovery आसान हो और data corrupt न हो।

Types of File Organization in DBMS

DBMS में storage architecture और access method के आधार पर 5 मुख्य प्रकार की file organization techniques होती हैं:

1. Sequential File Organization

Sequential file organization में सभी records को एक खास search key (आमतौर पर Primary Key) के fixed order (ascending या descending) में store किया जाता है। जैसे roll number 101, 102, 103 के क्रम में records disk blocks में लिखे जाते हैं।

[Block 1: Rec 101 | Rec 102] ---> [Block 2: Rec 103 | Rec 104] ---> [Block 3: Rec 105 | Rec 106]
  • Record Retrieval: अगर file sorted है, तो specific record ढूंढने के लिए Binary Search लग सकता है। लेकिन अगर magnetic tape जैसा storage media हो, तो शुरू से एक-एक करके आगे बढ़ना पड़ता है।
  • Insertion: नया record सही जगह पर बीच में डालना बहुत भारी काम है, क्योंकि आगे के सभी records को shift करना पड़ता है या overflow blocks का use करना पड़ता है।
  • Advantages: Range queries (जैसे Roll No 50 से 100 तक का data) और batch processing (जैसे सब employees की salary slip एक साथ print करना) के लिए सबसे fast है।
  • Disadvantages: Random access slow होता है। Record insert और delete करने पर file reorganization करनी पड़ती है।

2. Heap File Organization (Unordered File Organization)

Heap file organization सबसे simple technique है। इसमें records का कोई खास order या sorting नहीं होती। जब भी कोई नया record आता है, उसे file के सबसे आखिरी block में खाली जगह पर append कर दिया जाता है।

[Block 1: Rec 205 | Rec 102]
[Block 2: Rec 450 | Rec 110]
[Block 3: Rec 301 | (New Record goes here)]
  • Insertion: बहुत तेज़ (O(1) time)। बस आखिरी page ढूंढो और record लिख दो।
  • Searching: बहुत slow (O(n) time)। अगर Roll No 110 खोजना है, तो पहले block से लेकर आखिरी block तक linear search करना पड़ता है।
  • Deletion: Record को delete mark कर दिया जाता है। इससे disk blocks में खाली holes (wasted space) छूट जाते हैं, जिन्हें साफ करने के लिए बाद में garbage collection या file reorganization करना पड़ता है।
  • Best Use: जहाँ data केवल fast insert करना हो (जैसे log files, sensor readings) और search बहुत कम होता हो।

3. Hash File Organization (Direct File Organization)

Hash file organization में record किस block में store होगा, यह एक mathematical formula तय करता है जिसे Hash Function कहते हैं। Hash function primary key की value लेकर एक direct block address (bucket address) calculate करता है: h(Key) = Bucket Address।

Key (Roll No: 105) ---> [ Hash Function h(k) = k mod 5 ] ---> Bucket 0
Key (Roll No: 102) ---> [ Hash Function h(k) = k mod 5 ] ---> Bucket 2

Bucket 0: [Rec 105]
Bucket 1: [Rec 101]
Bucket 2: [Rec 102]
Bucket 3: [Rec 103]
Bucket 4: [Rec 104]
  • Direct Access: अगर आपको Roll No 105 खोजना है, तो system hash function से तुरंत bucket 0 का address निकाल लेगा और सीधे उसी block को read करेगा। Searching time O(1) होता है।
  • Hash Collision: जब दो अलग keys का hash output एक ही bucket address आ जाए (जैसे 105 और 110 दोनों का output 0 आ जाए), तो इसे collision कहते हैं। इसे handle करने के लिए Overflow Chaining (linked list of blocks) या Open Addressing (अगला खाली slot) इस्तेमाल किया जाता है।
  • Advantages: Exact key match search (point query) के लिए दुनिया का सबसे तेज़ method।
  • Disadvantages: Range query (जैसे Roll No 10 से 50 तक) बिल्कुल काम नहीं करती, क्योंकि पास-पास वाले numbers अलग-अलग buckets में बिखर जाते हैं।

4. Indexed Sequential File Organization (ISAM)

यह sequential file और index का combination है। इसमें records disk पर primary key के order में sorted होते हैं, और साथ में एक अलग Index File बनाई जाती है। Index file बिल्कुल book के index की तरह काम करती है: इसमें search key और उस record का physical block address (pointer) होता है।

[Index File]                     [Data Blocks on Disk]
Key  | Block Pointer             
101  | Block 1 ----------> Block 1: [101: Aman  | 102: Bharat | 103: Chitra]
104  | Block 2 ----------> Block 2: [104: Deepak| 105: Ekta   | 106: Farhan]
107  | Block 3 ----------> Block 3: [107: Geeta | 108: Harsh  | 109: Ishan]

Index दो तरह के होते हैं:

  • Dense Index: Data file के हर एक record के लिए index file में एक entry होती है। Search fast होता है लेकिन index file बड़ी बनती है।
  • Sparse Index: Data file के हर block के सिर्फ पहले record (anchor record) के लिए index file में entry होती है। यह कम memory लेता है।
  • Advantages: Random access और sequential access दोनों तेज़ होते हैं। Range queries भी आसानी से run होती हैं।
  • Disadvantages: Index file को store करने के लिए extra disk space चाहिए। जब data update या delete होता है, तो index को भी rebuild या update करना पड़ता है।

5. Clustered File Organization

Real-world relational databases में queries अक्सर दो tables को JOIN करके data निकालती हैं। Normal systems में दोनों tables अलग-अलग blocks में होती हैं, जिससे दोनों को अलग-अलग disk I/O से पढ़ना पड़ता है।

Clustered file organization में दो या दो से ज़्यादा related tables के records, जो अक्सर एक साथ access होते हैं, उन्हें एक ही disk block में साथ-साथ store किया जाता है। जैसे Department table और Employee table:

[Disk Block 1]
Dept 10: Computer Science
  - Emp 101: Rahul (CS)
  - Emp 102: Neha (CS)
------------------------------------
[Disk Block 2]
Dept 20: Mechanical
  - Emp 201: Amit (Mech)
  - Emp 202: Suresh (Mech)
  • Advantages: Join queries का disk I/O बहुत घट जाता है। एक ही read operation में department और उसके सभी employees का data RAM में आ जाता है।
  • Disadvantages: अगर सिर्फ employee table को scan करना हो, तो फालतू department data भी read होता है। Record update और space management complex हो जाता है।

Solved Example: Search Time और Disk Block Access Comparison

यूनिवर्सिटी numericals और practical analysis के लिए एक real scenario देखते हैं। मान लें हमारे पास एक university का student database है:

  • Total records in file = 1,00,000 records
  • Record size = 100 bytes
  • Disk block size = 4,096 bytes (4 KB)
Advertisement

Step 1: Blocking Factor (Bfr) की Calculation

एक disk block में कितने records आ सकते हैं:

Bfr = Floor(Block Size / Record Size)
Bfr = Floor(4096 / 100) = 40 records per block

Step 2: Total Disk Blocks (b) की Calculation

Total Blocks (b) = Ceiling(Total Records / Bfr)
b = Ceiling(1,00,000 / 40) = 2,500 blocks

Step 3: अलग-अलग File Organizations में Search Cost (Disk I/O)

File Organization Type Search Algorithm Block Accesses की Calculation Total Disk Reads
Heap File Linear Search (Average) b / 2 = 2500 / 2 1,250 block reads (बहुत slow)
Sequential File Binary Search log2(b) = log2(2500) ≈ 12 12 block reads
Indexed (Sparse Index) Index Binary Search + 1 Data Block Index size = 2500 entries / 100 per block = 25 blocks. log2(25) + 1 ≈ 5 + 1 6 block reads
Hash File Direct Hashing (No collision) Direct calculation of block address 1 block read (सबसे तेज़)

इस calculation से साफ़ दिखता है कि Heap file में औसतन 1,250 बार disk पढ़नी पड़ती है, जबकि Hash file में सिर्फ 1 read में record मिल जाता है।

Comparison: Types of File Organization in DBMS

Feature Sequential Heap (Unordered) Hash (Direct) Indexed (ISAM)
Record Order Search Key पर sorted कोई order नहीं (arrival order) Hash value के base पर Key पर sorted + index file
Search Speed (Point Query) Medium (Binary search: O(log n)) Slow (Linear search: O(n)) Very Fast (O(1)) Fast (O(log n))
Range Query Support Excellent Poor Supported नहीं है Very Good
Insertion Cost High (records shift करने पड़ते हैं) Very Low (O(1), end में append) Low (अगर collision न हो) Medium (index update ज़रूरी)
Storage Overhead Zero (extra file नहीं) Zero Low (खाली buckets का space) Medium to High (index file space)
Best Use Case Payroll, monthly electricity billing Bulk data insert, audit logs Account balance lookup, e-commerce cart Library system, student records

File Organization का चुनाव कैसे करें?

Database design करते समय file organization चुनने के 4 मुख्य नियम हैं:

  1. अगर Queries ज्यादातर Range-based हैं: जैसे "Marks between 60 and 80" या "Date between 1 Jan to 31 Jan", तो Sequential या B+ Tree Indexed File Organization चुनें। Hash कभी न चुनें।
  2. अगर Exact Key Match चाहिए: जैसे "Find customer where Account_No = 987654321", तो Hash File Organization सबसे best है।
  3. अगर Write Speed सबसे important है: जैसे server logs, IoT devices का data जहाँ हर second लाखों records सिर्फ save होते हैं और search कभी-कभार होता है, तो Heap File चुनें।
  4. अगर Random और Sequential दोनों Access चाहिए: तो Indexed Sequential File Organization (ISAM) चुनें।

Exam में कैसे लिखें (5 marks)

BCA/B.Tech semester exam में अगर 5 marks का question "Explain File Organization in DBMS" आए, तो answer sheet में सीधे इस structure में 10 points लिखें:

  1. Definition: File organization वह physical arrangement है जिसके अनुसार data records को hard disk के blocks में store और access किया जाता है।
  2. Goal: इसका मुख्य उद्देश्य disk access time (I/O operations) घटाना और storage space बचाना है।
  3. Sequential: Records primary key के sorted order में रखे जाते हैं। Range queries और batch processing के लिए best है।
  4. Heap: Records बिना किसी order के append होते हैं। Insert fast (O(1)) होता है, लेकिन search slow (linear search O(n)) होता है।
  5. Hash: Hash function h(k) से record का direct bucket address निकलता है। Point query O(1) में solve होती है, लेकिन range query support नहीं करता।
  6. Indexed (ISAM): Data file के साथ एक index file रखी जाती है। Random और sequential दोनों queries fast चलती हैं।
  7. Clustered: बार-बार join होने वाले related tables (जैसे Department और Employee) के records को एक ही block में साथ रखा जाता है।
  8. Data Hierarchy: Bit → Byte → Field → Record → File → Database.
  9. A collection of files: Related files के group को Database कहते हैं।
  10. Diagram: Copy में Sequential block chain और Hash bucket का छोटा diagram ज़रूर बनाएं (पूरे marks मिलते हैं)।

Common Mistakes जो Students करते हैं

  • File Organization और Access Method को एक समझ लेना: File organization storage का physical structure है (data disk पर कैसे रखा है), जबकि access method वह logic/algorithm है जिससे data को पढ़ा जाता है।
  • Hash Organization में Range Query search करना: बहुत से students लिख देते हैं कि Hash organization से Roll No 10 से 30 तक search कर सकते हैं। यह गलत है; Hashing केवल exact value match (equality search) कर सकती है।
  • Index File का overhead भूल जाना: Index से search तो fast होता है, लेकिन हर INSERT, UPDATE, और DELETE पर index file को भी update करना पड़ता है।
  • Heap File को Binary Heap Tree समझ लेना: DBMS में Heap File का मतलब सिर्फ unordered (बिना क्रम वाली) file है। इसका Data Structures वाले Min-Heap या Max-Heap binary tree से कोई लेना-देना नहीं है।

Exam के लिए Important Questions

Short Questions (2–3 marks)

  1. DBMS में File Organization क्या है? (Records को secondary storage blocks पर store और retrieve करने का systematic method)
  2. A collection of files is called what? (Related files के organized collection को Database कहते हैं, और OS level पर इसे Directory या Folder कहते हैं)
  3. Dense Index और Sparse Index में क्या अंतर है? (Dense index में हर record की entry होती है; Sparse index में सिर्फ हर block के पहले record की entry होती है)
  4. Hash Collision क्या होता है? (जब दो अलग search keys के लिए hash function एक ही bucket address return करे)
  5. Blocking Factor (Bfr) क्या है? (एक disk block के अंदर store किए जा सकने वाले total records की संख्या)

Long Questions (5–10 marks)

  1. File Organization in DBMS क्या है? Sequential, Hash, और Indexed File Organization को diagram और examples के साथ detail में समझाइए।
  2. Heap File Organization और Hash File Organization की तुलना कीजिए। Search, Insert और Delete operations में दोनों की time complexity क्या है?
  3. Clustered File Organization क्या है? यह SQL JOIN queries की performance को कैसे improve करता है? Real-life example से स्पष्ट कीजिए।

FAQs

DBMS में File Organization in Hindi का सबसे आसान मतलब क्या है?

इसका मतलब है कि आपकी database table का data hard disk पर किस तरतीब या order में रखा गया है, ताकि जब भी कोई user query चलाए, तो कम से कम समय में data screen पर लाया जा सके।

Group of files या collection of files is called what?

DBMS में related files के group को Database कहा जाता है। Computer system या operating system में इसे Directory या Folder कहते हैं।

Real-world databases जैसे MySQL और Oracle कौन सा file organization इस्तेमाल करते हैं?

Production databases आमतौर पर B+ Tree Indexed File Organization इस्तेमाल करते हैं (जैसे MySQL का InnoDB engine)। यह Indexed और Sequential दोनों के फायदे देता है, जिससे point queries और range queries दोनों बहुत fast execute होती हैं।

Hash file organization में range search क्यों नहीं होती?

क्योंकि hash function sequential order को तोड़ देता है। Roll No 101 bucket 1 में जा सकता है और Roll No 102 bucket 9 में। इसलिए 101 से 110 के बीच का data खोजने के लिए पूरे disk blocks को अलग-अलग ढूंढना पड़ेगा, जो बहुत inefficient होता है।

अक्सर पूछे जाने वाले प्रश्न (FAQs)

Quick Answer: DBMS में File Organization वह तरीका है जिससे records को physical storage (hard disk या SSD) पर blocks के रूप में arrange और store किया जाता है, ताकि data को कम से कम समय और कम disk I/O में access (read, search, insert, update) किया जा सके।
DBMS Notes in Hindi | डीबीएमएस नोट्स के पाठ्यक्रम में File Organization In Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको File Organization In Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement