SlideShare a Scribd company logo
1 of 13
PRIMARY
STORAGE
SECONDARY
STORAGE
1)Faster Access Slower Access
2)Expensive Cheaper
3)Lesser storage
capacity
Greater Storage
capacity
4)Temporary Storage Permanent Storage
 Secondary Storage Structure
 Used for permanent storage
 It’s a collection of records or a stream of bytes
 Every Record is a collection of fields
 A particular field is chosen as a Key
 Records are organised in file by using the key. Primary
and secondary keys.
 Consider a student database.
 Every student has a unique record
 Record has details of student-i.e name, Student
ID etc. These are the fields.
 The unique key can be the Student ID. The
records can be organised in the file on basis of
student ID.
 Sometimes data is too large to be stored in main
memory.
 Maintaining permanent record is possible only by
using a secondary storage. Hence files.
 Physical Files:
A collection of bits stored in the secondary storage
device
 Logical File:
A channel that connects he program to the physical
file(Stream).
An example
FILE* out
out=fopen(“sample.txt”,”w”);
Here out is the logical file and sample.txt is the
physical file.
 Opening a File:
A logical file is associated with the physical file
 Closing a File:
The logical file associated with the physical file is freed.
fclose(file pointer);
 Reading from file:
Data present in physical file is read by using the logical file
 Writing to a File
Data can be written to physical file by using the logical file
 Every logical file has a file position pointer.
 When we open a new stream the position pointer
is set to beginning of the file.
 As data is read or written the file position pointer is
moved accordingly.
 To move file pointer to required position.
fseek(file pointer,offset, position); 
 To display current location of pointer.
long position=ftell(pointer);
 To check for end of file
while(!feof(pointer));
 Sequential File
Stored in the order entered
 Random Access Files
An record is accessed using an index.(Hashing).
 Direct Access Files:
The records are stored based on their relative
position with respect to first record.
Record with key 50 is placed at location 50
 Records are stored in the order entered
 Used when all the records have to be processed.
 Complexity for searching O(n)
 An record is accessed using an index.
 The index of record position in file has to be
maintained in the main memory.
 The Index can be created using hashing.
 Search complexity is less. Complexity of Indexing
method used.
 Disadvantage: While handling very large
databases its not possible to maintain an index in
the main memory.
 The records are stored based on their relative
position with respect to first record.
 Record with key 50 is placed at location 50
 The search complexity is O(1)
 Disadvantage is a lot of memory is wasted.
 For example if no record has key 100 the position
100 is wasted.

More Related Content

What's hot

File organization
File organizationFile organization
File organizationGokul017
 
Fileorganization AbnMagdy
Fileorganization AbnMagdyFileorganization AbnMagdy
Fileorganization AbnMagdyMohamed Magdy
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure ConceptsDileep Kodira
 
File organization 1
File organization 1File organization 1
File organization 1Rupali Rana
 
Switching & Multiplexing
Switching & MultiplexingSwitching & Multiplexing
Switching & MultiplexingMelkamuEndale1
 
File organization continued
File organization continuedFile organization continued
File organization continuedchesterking12
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structuresDevyani Vaidya
 
File management
File managementFile management
File managementsumathiv9
 
Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File OrganizationMISY
 
File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexingraveena sharma
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for filesZainab Almugbel
 
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary fileCBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary fileShivaniJayaprakash1
 

What's hot (20)

File organization
File organizationFile organization
File organization
 
File organisation
File organisationFile organisation
File organisation
 
Fileorganization AbnMagdy
Fileorganization AbnMagdyFileorganization AbnMagdy
Fileorganization AbnMagdy
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 
File organization
File organizationFile organization
File organization
 
File organisation
File organisationFile organisation
File organisation
 
Handling computer files
Handling computer filesHandling computer files
Handling computer files
 
File organisation
File organisationFile organisation
File organisation
 
File organization 1
File organization 1File organization 1
File organization 1
 
C files
C filesC files
C files
 
Switching & Multiplexing
Switching & MultiplexingSwitching & Multiplexing
Switching & Multiplexing
 
File organization continued
File organization continuedFile organization continued
File organization continued
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structures
 
File management
File managementFile management
File management
 
File Management
File ManagementFile Management
File Management
 
Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File Organization
 
File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexing
 
itft-File design
itft-File designitft-File design
itft-File design
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
 
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary fileCBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
 

Similar to File structures

Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systemsdonny101
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingZainab Almugbel
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxarmaansohail9356
 
text and binary sequential and random files with modes
text and binary sequential and random files with modestext and binary sequential and random files with modes
text and binary sequential and random files with modesAnimecartoon1
 
Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptgeethasenthil2706
 
Introduction to File System
Introduction to File SystemIntroduction to File System
Introduction to File SystemSanthiNivas
 
FIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptxFIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptxAshwini Raut
 
Fundamental File Processing Operations
Fundamental File Processing OperationsFundamental File Processing Operations
Fundamental File Processing OperationsDon Bosco BSIT
 
presentation_files_1451938150_140676.ppt
presentation_files_1451938150_140676.pptpresentation_files_1451938150_140676.ppt
presentation_files_1451938150_140676.pptansariparveen06
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file managementKalai Selvi
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating SystemJanki Shah
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
 

Similar to File structures (20)

Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systems
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
 
FILES IN C
FILES IN CFILES IN C
FILES IN C
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashing
 
File Systems
File SystemsFile Systems
File Systems
 
File management
File managementFile management
File management
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 
text and binary sequential and random files with modes
text and binary sequential and random files with modestext and binary sequential and random files with modes
text and binary sequential and random files with modes
 
Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems ppt
 
Introduction to File System
Introduction to File SystemIntroduction to File System
Introduction to File System
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
 
pspp-rsk.pptx
pspp-rsk.pptxpspp-rsk.pptx
pspp-rsk.pptx
 
FIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptxFIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptx
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
Fundamental File Processing Operations
Fundamental File Processing OperationsFundamental File Processing Operations
Fundamental File Processing Operations
 
presentation_files_1451938150_140676.ppt
presentation_files_1451938150_140676.pptpresentation_files_1451938150_140676.ppt
presentation_files_1451938150_140676.ppt
 
files in c ppt.ppt
files in c ppt.pptfiles in c ppt.ppt
files in c ppt.ppt
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 

File structures

  • 1.
  • 2. PRIMARY STORAGE SECONDARY STORAGE 1)Faster Access Slower Access 2)Expensive Cheaper 3)Lesser storage capacity Greater Storage capacity 4)Temporary Storage Permanent Storage
  • 3.  Secondary Storage Structure  Used for permanent storage  It’s a collection of records or a stream of bytes  Every Record is a collection of fields  A particular field is chosen as a Key  Records are organised in file by using the key. Primary and secondary keys.
  • 4.  Consider a student database.  Every student has a unique record  Record has details of student-i.e name, Student ID etc. These are the fields.  The unique key can be the Student ID. The records can be organised in the file on basis of student ID.
  • 5.  Sometimes data is too large to be stored in main memory.  Maintaining permanent record is possible only by using a secondary storage. Hence files.
  • 6.  Physical Files: A collection of bits stored in the secondary storage device  Logical File: A channel that connects he program to the physical file(Stream). An example FILE* out out=fopen(“sample.txt”,”w”); Here out is the logical file and sample.txt is the physical file.
  • 7.  Opening a File: A logical file is associated with the physical file  Closing a File: The logical file associated with the physical file is freed. fclose(file pointer);  Reading from file: Data present in physical file is read by using the logical file  Writing to a File Data can be written to physical file by using the logical file
  • 8.  Every logical file has a file position pointer.  When we open a new stream the position pointer is set to beginning of the file.  As data is read or written the file position pointer is moved accordingly.
  • 9.  To move file pointer to required position. fseek(file pointer,offset, position);   To display current location of pointer. long position=ftell(pointer);  To check for end of file while(!feof(pointer));
  • 10.  Sequential File Stored in the order entered  Random Access Files An record is accessed using an index.(Hashing).  Direct Access Files: The records are stored based on their relative position with respect to first record. Record with key 50 is placed at location 50
  • 11.  Records are stored in the order entered  Used when all the records have to be processed.  Complexity for searching O(n)
  • 12.  An record is accessed using an index.  The index of record position in file has to be maintained in the main memory.  The Index can be created using hashing.  Search complexity is less. Complexity of Indexing method used.  Disadvantage: While handling very large databases its not possible to maintain an index in the main memory.
  • 13.  The records are stored based on their relative position with respect to first record.  Record with key 50 is placed at location 50  The search complexity is O(1)  Disadvantage is a lot of memory is wasted.  For example if no record has key 100 the position 100 is wasted.