SlideShare a Scribd company logo
1 of 13
File structures
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

What's hot (20)

11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
FILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMSFILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMS
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
File organisation
File organisationFile organisation
File organisation
 
File system structure
File system structureFile system structure
File system structure
 
File organization
File organizationFile organization
File organization
 
Indexing and Hashing
Indexing and HashingIndexing and Hashing
Indexing and Hashing
 
Data cubes
Data cubesData cubes
Data cubes
 
Sql fundamentals
Sql fundamentalsSql fundamentals
Sql fundamentals
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
Data warehouse architecture
Data warehouse architecture Data warehouse architecture
Data warehouse architecture
 
Database recovery
Database recoveryDatabase recovery
Database recovery
 
Array data structure
Array data structureArray data structure
Array data structure
 
Parallel Database
Parallel DatabaseParallel Database
Parallel Database
 
The database applications
The database applicationsThe database applications
The database applications
 
Codd's rules
Codd's rulesCodd's rules
Codd's rules
 
File system Os
File system OsFile system Os
File system Os
 
Metadata ppt
Metadata pptMetadata ppt
Metadata ppt
 
Temporal databases
Temporal databasesTemporal databases
Temporal databases
 

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 OperationsRico
 
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 Types in Data Structure
File Types in Data StructureFile Types in Data Structure
File Types in Data StructureProf Ansari
 

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
 
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 Types in Data Structure
File Types in Data StructureFile Types in Data Structure
File Types in Data Structure
 

Recently uploaded

IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncObject Automation
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxYounusS2
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 

Recently uploaded (20)

IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation Inc
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptx
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 

File structures

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