SlideShare a Scribd company logo
1 of 17
1
Fundamental File Structure
Concepts & Managing Files of
Records
2
Outline I: Fundamental File
Structure Concepts
• Stream Files
• Field Structures
• Reading a Stream of Fields
• Record Structures
• Record Structures that use a length
indicator
3
Outline II: Managing Files of
Records
• Record Access
• More About Record Structures
• File Access and File Organization
• More Complex File Organization and
Access
• Portability and Standardization
4
Field and Record Organization:
Overview
• The basic logical unit of data is the field which
contains a single data value.
• Fields are organized into aggregates, either as
many copies of a single field (an array) or as a list
of different fields (a record).
• When a record is stored in memory, we refer to it
as an object and refer to its fields as members.
• In this lecture, we will investigate the many ways
that objects can be represented as records in files.
5
Stream Files
• Mary Ames
• 123 Maple
• Stillwater, OK 74075
• Alan Mason
• 90 Eastgate
• Ada, OK 74820
n Stream Files, the information is written as a
eam of bytes containing no added information:
mesMary123 MapleStillwaterOK74075MasonAlan90 EastgateAdaOK7
Problem: There is no way to get the information
ck in the organized record format.
6
Field Structures
• There are many ways of adding structure to
files to maintain the identity of fields:
– Force the field into a predictable length
– Begin each field with a length indicator
– Use a “keyword = value” expression to
identify each field and its content.
7
Reading a Stream of Fields
• A Program can easily
read a stream of fields
and output ===>
• This time, we do
preserve the notion of
fields, but something
is missing: Rather than
a stream of fields,
these should be two
records
Last Name: ‘Ames’
First Name: ‘Mary’
Address: ‘123 Maple’
City: ‘Stillwater
State: ‘OK’
Zip Code: ‘74075’
Last Name: ‘Mason’
First Name: ‘Alan’
Address: ‘90 Eastgate’
City: ‘Ada’
State: ‘OK’
Zip Code: ‘74820’
8
Record Structure I
• A record can be defined as a set of fields
that belong together when the file is viewed
in terms of a higher level of organization.
• Like the notion of a field, a record is
another conceptual tool which needs not
exist in the file in any physical sense.
• Yet, they are an important logical notion
included in the file’s structure.
9
Record Structures II
• Methods for organizing the records of a file include:
– Requiring that the records be a predictable number
of bytes in length.
– Requiring that the records be a predictable number
of fields in length.
– Beginning each record with a length indicator
consisting of a count of the number of bytes that
the record contains.
– Using a second file to keep track of the beginning
byte address for each record.
– Placing a delimiter at the end of each record to
separate it from the next record.
10
Record Structures that Use a
Length Indicator
• The notion of records that we implemented are
lacking something: none of the variability in the
length of records that was inherent in the initial
stream file was conserved.
• Implementation:
– Writing the variable-length records to the file
– Representing the record length
– Reading the variable-length record from the
file.
11
Record Access: Keys
• When looking for an individual record, it is
convenient to identify the record with a key
based on the record’s content (e.g., the
Ames record).
• Keys should uniquely define a record and
be unchanging.
• Records can also be searched based on a
secondary key. Those do not typically
uniquely identify a record.
12
Sequential Search
• Evaluating Performance of Sequential
Search.
• Improving Sequential Search Performance
with Record Blocking.
• When is Sequential Search Useful?
13
Direct Access
• How do we know where the beginning of the
required record is?
It may be in an Index (discussed in a different
lecture)
We know the relative record number (RRN)
• RRN are not useful when working with variable
length-records: the access is still sequential.
• With fixed-length records, however, they are
useful.
14
Record Structure
• Choosing a Record Structure and Record Length
within a fixed-length record. 2 approaches:
– Fixed-Length Fields in record (simple but
problematic).
– Varying Field boundaries within the fixed-
length record.
• Header Records are often used at the beginning of
the file to hold some general info about a file to
assist in future use of the file.
15
File Access and File
Organization: A Summary
• File organization depends on what use you want to
make of the file.
• Since using a file implies accessing it, file access
and file organization are intimately linked.
• Example: though using fixed-length records
makes direct access easier, if the documents have
very variable lengths, fixed-length records is not a
good solution: the application determines our
choice of both access and organization.
16
Beyond Record Structure
• Abstract Data Models for File Access
• Headers and Self-Describing File
• Metadata
• Color Raster Images
• Mixing Object Types in One File
• Representation-Independent File Access
• Extensibility
17
Portability and Standardization
• Factors Affecting Portability
– Differences among Operating Systems
– Differences among Languages
– Differences in Machine Architectures
• Achieving Portability
– Agree on a Standard Physical Record Format and Stay
with it
– Agree on a Standard Binary Encoding for Data Elements
– Number and Text Conversion
– File Structure Conversion
– File System Differences
– Unix and Portability

More Related Content

What's hot

What's hot (20)

Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
File organization
File organizationFile organization
File organization
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
storage media
storage mediastorage media
storage media
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
File handling in C
File handling in CFile handling in C
File handling in C
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
File Management in C
File Management in CFile Management in C
File Management in C
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
static libraries and dynamic libraries
static libraries and dynamic librariesstatic libraries and dynamic libraries
static libraries and dynamic libraries
 
Record storage and primary file organization
Record storage and primary file organizationRecord storage and primary file organization
Record storage and primary file organization
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
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
 
Transaction Management
Transaction Management Transaction Management
Transaction Management
 
Process of operating system
Process of operating systemProcess of operating system
Process of operating system
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-thread
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
 

Similar to Fundamental file structure concepts & managing files of records

DFS-Lecture-6 (3).ppt
DFS-Lecture-6 (3).pptDFS-Lecture-6 (3).ppt
DFS-Lecture-6 (3).pptSatvik93
 
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
 
Data Indexing Presentation-My.pptppt.ppt
Data Indexing Presentation-My.pptppt.pptData Indexing Presentation-My.pptppt.ppt
Data Indexing Presentation-My.pptppt.pptsdsm2
 
UNIT7-FileMgmt.pptx
UNIT7-FileMgmt.pptxUNIT7-FileMgmt.pptx
UNIT7-FileMgmt.pptxNavyaKumar22
 
File Structure.pptx
File Structure.pptxFile Structure.pptx
File Structure.pptxzedd15
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdfFraolUmeta
 
Chapter 3 Indexing Structure.pdf
Chapter 3 Indexing Structure.pdfChapter 3 Indexing Structure.pdf
Chapter 3 Indexing Structure.pdfJemalNesre1
 
FIle Organization.pptx
FIle Organization.pptxFIle Organization.pptx
FIle Organization.pptxSreenivas R
 
storage techniques_overview-1.pptx
storage techniques_overview-1.pptxstorage techniques_overview-1.pptx
storage techniques_overview-1.pptx20CS102RAMMPRASHATHK
 
File_Organization_112014
File_Organization_112014File_Organization_112014
File_Organization_112014eshuppy
 
DBMS_UNIT 5 Notes.pptx
DBMS_UNIT 5 Notes.pptxDBMS_UNIT 5 Notes.pptx
DBMS_UNIT 5 Notes.pptxJayendranath3
 
2.7 use of ict in data management
2.7 use of ict in data management2.7 use of ict in data management
2.7 use of ict in data managementHaa'Meem Mohiyuddin
 
File organization
File organizationFile organization
File organizationGokul017
 

Similar to Fundamental file structure concepts & managing files of records (20)

DFS-Lecture-6 (3).ppt
DFS-Lecture-6 (3).pptDFS-Lecture-6 (3).ppt
DFS-Lecture-6 (3).ppt
 
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
 
Data Indexing Presentation-My.pptppt.ppt
Data Indexing Presentation-My.pptppt.pptData Indexing Presentation-My.pptppt.ppt
Data Indexing Presentation-My.pptppt.ppt
 
3_Indexing.ppt
3_Indexing.ppt3_Indexing.ppt
3_Indexing.ppt
 
UNIT7-FileMgmt.pptx
UNIT7-FileMgmt.pptxUNIT7-FileMgmt.pptx
UNIT7-FileMgmt.pptx
 
File Structure.pptx
File Structure.pptxFile Structure.pptx
File Structure.pptx
 
File System.pptx
File System.pptxFile System.pptx
File System.pptx
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdf
 
File Management
File ManagementFile Management
File Management
 
File Management
File ManagementFile Management
File Management
 
Chapter 3 Indexing Structure.pdf
Chapter 3 Indexing Structure.pdfChapter 3 Indexing Structure.pdf
Chapter 3 Indexing Structure.pdf
 
FIle Organization.pptx
FIle Organization.pptxFIle Organization.pptx
FIle Organization.pptx
 
storage techniques_overview-1.pptx
storage techniques_overview-1.pptxstorage techniques_overview-1.pptx
storage techniques_overview-1.pptx
 
File_Organization_112014
File_Organization_112014File_Organization_112014
File_Organization_112014
 
DBMS_UNIT 5 Notes.pptx
DBMS_UNIT 5 Notes.pptxDBMS_UNIT 5 Notes.pptx
DBMS_UNIT 5 Notes.pptx
 
2.7 use of ict in data management
2.7 use of ict in data management2.7 use of ict in data management
2.7 use of ict in data management
 
File organization
File organizationFile organization
File organization
 
File organisation
File organisationFile organisation
File organisation
 
file management
file managementfile management
file management
 

More from Devyani Vaidya

Cosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesCosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesDevyani Vaidya
 
Cloud Cmputing Security
Cloud Cmputing SecurityCloud Cmputing Security
Cloud Cmputing SecurityDevyani Vaidya
 
Wireless mobile charging using microwaves
Wireless mobile charging using microwavesWireless mobile charging using microwaves
Wireless mobile charging using microwavesDevyani Vaidya
 
Energy Harvesing Through Reverse Electrowetting
Energy Harvesing Through Reverse Electrowetting Energy Harvesing Through Reverse Electrowetting
Energy Harvesing Through Reverse Electrowetting Devyani Vaidya
 
Wireless Charging Of Mobile
Wireless Charging Of Mobile  Wireless Charging Of Mobile
Wireless Charging Of Mobile Devyani Vaidya
 
Seminar on telephone directory
Seminar on telephone directorySeminar on telephone directory
Seminar on telephone directoryDevyani Vaidya
 
Ppt on open and close door using Applet
Ppt on open and close door using Applet Ppt on open and close door using Applet
Ppt on open and close door using Applet Devyani Vaidya
 
Ppt on use of biomatrix in secure e trasaction
Ppt on use of biomatrix in secure e trasactionPpt on use of biomatrix in secure e trasaction
Ppt on use of biomatrix in secure e trasactionDevyani Vaidya
 

More from Devyani Vaidya (20)

Hashing
HashingHashing
Hashing
 
Cosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesCosequential processing and the sorting of large files
Cosequential processing and the sorting of large files
 
Mobile Phone Cloning
 Mobile Phone Cloning Mobile Phone Cloning
Mobile Phone Cloning
 
Data warehousing
Data warehousingData warehousing
Data warehousing
 
secued cloud
 secued cloud secued cloud
secued cloud
 
Cloud Cmputing Security
Cloud Cmputing SecurityCloud Cmputing Security
Cloud Cmputing Security
 
Cloud Security
Cloud SecurityCloud Security
Cloud Security
 
Wireless network
Wireless networkWireless network
Wireless network
 
Environmental law
Environmental lawEnvironmental law
Environmental law
 
Wireless mobile charging using microwaves
Wireless mobile charging using microwavesWireless mobile charging using microwaves
Wireless mobile charging using microwaves
 
Secure Cloud Issues
Secure Cloud IssuesSecure Cloud Issues
Secure Cloud Issues
 
Energy Harvesing Through Reverse Electrowetting
Energy Harvesing Through Reverse Electrowetting Energy Harvesing Through Reverse Electrowetting
Energy Harvesing Through Reverse Electrowetting
 
Wireless Charging Of Mobile
Wireless Charging Of Mobile  Wireless Charging Of Mobile
Wireless Charging Of Mobile
 
Applet programming
Applet programming Applet programming
Applet programming
 
Seminar on telephone directory
Seminar on telephone directorySeminar on telephone directory
Seminar on telephone directory
 
History of Laptop
History of LaptopHistory of Laptop
History of Laptop
 
Ppt on open and close door using Applet
Ppt on open and close door using Applet Ppt on open and close door using Applet
Ppt on open and close door using Applet
 
Resource management
Resource managementResource management
Resource management
 
Ppt on use of biomatrix in secure e trasaction
Ppt on use of biomatrix in secure e trasactionPpt on use of biomatrix in secure e trasaction
Ppt on use of biomatrix in secure e trasaction
 
Secued Cloud
 Secued  Cloud Secued  Cloud
Secued Cloud
 

Recently uploaded

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 

Recently uploaded (20)

Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 

Fundamental file structure concepts & managing files of records

  • 1. 1 Fundamental File Structure Concepts & Managing Files of Records
  • 2. 2 Outline I: Fundamental File Structure Concepts • Stream Files • Field Structures • Reading a Stream of Fields • Record Structures • Record Structures that use a length indicator
  • 3. 3 Outline II: Managing Files of Records • Record Access • More About Record Structures • File Access and File Organization • More Complex File Organization and Access • Portability and Standardization
  • 4. 4 Field and Record Organization: Overview • The basic logical unit of data is the field which contains a single data value. • Fields are organized into aggregates, either as many copies of a single field (an array) or as a list of different fields (a record). • When a record is stored in memory, we refer to it as an object and refer to its fields as members. • In this lecture, we will investigate the many ways that objects can be represented as records in files.
  • 5. 5 Stream Files • Mary Ames • 123 Maple • Stillwater, OK 74075 • Alan Mason • 90 Eastgate • Ada, OK 74820 n Stream Files, the information is written as a eam of bytes containing no added information: mesMary123 MapleStillwaterOK74075MasonAlan90 EastgateAdaOK7 Problem: There is no way to get the information ck in the organized record format.
  • 6. 6 Field Structures • There are many ways of adding structure to files to maintain the identity of fields: – Force the field into a predictable length – Begin each field with a length indicator – Use a “keyword = value” expression to identify each field and its content.
  • 7. 7 Reading a Stream of Fields • A Program can easily read a stream of fields and output ===> • This time, we do preserve the notion of fields, but something is missing: Rather than a stream of fields, these should be two records Last Name: ‘Ames’ First Name: ‘Mary’ Address: ‘123 Maple’ City: ‘Stillwater State: ‘OK’ Zip Code: ‘74075’ Last Name: ‘Mason’ First Name: ‘Alan’ Address: ‘90 Eastgate’ City: ‘Ada’ State: ‘OK’ Zip Code: ‘74820’
  • 8. 8 Record Structure I • A record can be defined as a set of fields that belong together when the file is viewed in terms of a higher level of organization. • Like the notion of a field, a record is another conceptual tool which needs not exist in the file in any physical sense. • Yet, they are an important logical notion included in the file’s structure.
  • 9. 9 Record Structures II • Methods for organizing the records of a file include: – Requiring that the records be a predictable number of bytes in length. – Requiring that the records be a predictable number of fields in length. – Beginning each record with a length indicator consisting of a count of the number of bytes that the record contains. – Using a second file to keep track of the beginning byte address for each record. – Placing a delimiter at the end of each record to separate it from the next record.
  • 10. 10 Record Structures that Use a Length Indicator • The notion of records that we implemented are lacking something: none of the variability in the length of records that was inherent in the initial stream file was conserved. • Implementation: – Writing the variable-length records to the file – Representing the record length – Reading the variable-length record from the file.
  • 11. 11 Record Access: Keys • When looking for an individual record, it is convenient to identify the record with a key based on the record’s content (e.g., the Ames record). • Keys should uniquely define a record and be unchanging. • Records can also be searched based on a secondary key. Those do not typically uniquely identify a record.
  • 12. 12 Sequential Search • Evaluating Performance of Sequential Search. • Improving Sequential Search Performance with Record Blocking. • When is Sequential Search Useful?
  • 13. 13 Direct Access • How do we know where the beginning of the required record is? It may be in an Index (discussed in a different lecture) We know the relative record number (RRN) • RRN are not useful when working with variable length-records: the access is still sequential. • With fixed-length records, however, they are useful.
  • 14. 14 Record Structure • Choosing a Record Structure and Record Length within a fixed-length record. 2 approaches: – Fixed-Length Fields in record (simple but problematic). – Varying Field boundaries within the fixed- length record. • Header Records are often used at the beginning of the file to hold some general info about a file to assist in future use of the file.
  • 15. 15 File Access and File Organization: A Summary • File organization depends on what use you want to make of the file. • Since using a file implies accessing it, file access and file organization are intimately linked. • Example: though using fixed-length records makes direct access easier, if the documents have very variable lengths, fixed-length records is not a good solution: the application determines our choice of both access and organization.
  • 16. 16 Beyond Record Structure • Abstract Data Models for File Access • Headers and Self-Describing File • Metadata • Color Raster Images • Mixing Object Types in One File • Representation-Independent File Access • Extensibility
  • 17. 17 Portability and Standardization • Factors Affecting Portability – Differences among Operating Systems – Differences among Languages – Differences in Machine Architectures • Achieving Portability – Agree on a Standard Physical Record Format and Stay with it – Agree on a Standard Binary Encoding for Data Elements – Number and Text Conversion – File Structure Conversion – File System Differences – Unix and Portability