Sei sulla pagina 1di 8

Physical Files

Physical files contain data and are subdivided into database & source physical files.
Physical files is the only type of file that actually contains data. Physical files are used when
there can be any number of IDENTICA!"#$%&ATTED entries 'each entry bein( a record)
%ecord #ormat* A record format is a template that defines the fields contained in each record.
This template has the name of the fields+ the type+ len(th and other characteristics.
%ecord format is a set of fields.
#ield is a sub"set of record 'or) a record format.
#ield definition is nothin( but definin( a part of total characters in a record len(th.
Definition means """"""", (ivin( name+ type+ len(th and other characteristics.
#or E(*

Assume that every new employee has to declare his-her various details while .oinin( your
company. The various details include name+ a(e+ (ender+ s/ill+ nationality+ permanent
address+ temporary address etc. 0e want one employee to fill up his-her details in one paper
and we put all those papers in one file folder. Assume now that we had (iven a white paper to
each new employee and as/ed them to fill up above said details.
1ecause we had (iven them .ust white papers to fill up particular details+ various
combinations of fillin( up the details are possible. Please chec/ below for a few possible
ways.
2
st
employee*
Name* 3arsh 4umar
A(e * 52
6ender* &ale
7/ill * C pro(rammer
Nationality* Indian
Permanent Address* Delhi
Temporary Address* 1an(alore
5
nd
employee*
Naresh 4umar+ 55+ &ale+ A7899 pro(rammer+ Indian+ &umbai+ Pune
:
rd
Employee*
7eema 4hanna+ #emale+ 5;
7/ill* %P6 pro(rammer
Address* New Delhi
This way we can create N number of possible way of fillin( up details on a white paper. This is
(enerally un"acceptable and not understandable in future readin(.
7o+ the or(ani<ation should create a format on the white paper before (ivin( them to
employees for fillin( up their details. The format can be li/e the followin(*
Employee details form
Name 'please use capital alphabetics only)*
A(e 'Numerics only)*
6ender 'capital alphabetics only)*
7/ill 'capital Alphanumerics)*
Nationality 'Capital Alphabetics only)*
Permanent Address 'Capital Alphanumerics only)*
Temporary Address 'Capital Alphanumerics only)*
This is called formattin( 'or blue print). 7o+ that any new employee will fill up particular detail
at particular specified location+ li/e name at =Name=+ a(e at =A(e= etc. Also+ note that it is
mentioned what should be used to fill up at each location. Name+ (ender and nationality
should be filled up usin( capital alphabetic letters only. 1oth addresses should be filled up
usin( Alphanumerics which allows for special characters too 'li/e "+- etc.). A(e should be filled
up usin( Numerics only+ it means employee should not write his a(e in letters li/e =Twenty
seven= etc. Also note that Name and addresses are (iven more space than other fields+
/eepin( in view that those details will be lar(er and re>uire more than one line.
7o+ formattin( 'or creatin( blue print) means definin( name of the specification 'li/e Name+
a(e etc.)+ its type 'li/e alphabets+ numerics or alphanumerics)+ len(th 'space re>uired)+ this is
definin( a specification of detail or field in the format. 0e can call it field definitions. 7o+
several Employee forms 'with same format) are created usin( blue print.
Now each employee fills up the formatted paper (iven to him-her and they are stored in a
folder called employee file. Each paper in that file is one record of one employee. In one
record of one employee+ each specification 'li/e Name+ A(e etc.) is called a field. If a set of
fields is record+ a field is called a sub"set of a record.
$ne should understand that record format 'blue print) is different from an ori(inal record. A
record format contains only definitions for a set of fields li/e name of each field+ its type and
its len(th.
E(* Chec/ below various formats*
Employee details file record format
#ield 2* Name+ Type Alphabetics+ len(th 599
#ield 5* A(e+ Type Numeric+ len(th 5
#ield :* s/ill+ Type Alphanumerics+ len(th 59
#iled 8* Nationality+ type alphabetics+ len(th 59
#ield ;* Permanent Address+ Type Alphanumerics+ len(th ?99
#ield @* Temporary Address+ Type Alphanumerics+ len(th ?99
Employee 7alary file record format
#ield 2* Name+ type alphabetics+ len(th 599
#ield 5* 7/ill+ type alphanumeric+ len(th 59
#ield :* eAperience years+ type floatin(+ len(th 8'two fields for decimal value)
#ield 8* present pro.ect+ type alphanumerics+ len(th 89
#ield ;* salary+ type floatin(+ len(th B
7o+ the 3% creates a soft copy of a form based on its record format 'or blue print) and ta/es a
print fillin( up details of a salary details of an employee. That paper becomes the record of
employee salary. And the file this paper is stored is called CEmployee salaryD file.
7o+ now we understood the difference between field and format+ difference between format
and actual record+ difference between record and file.
Assume that the 3% separately written format of each form in one paper. 7o+ if 3% is
maintainin( 299 files+ then there are 299 record formats 'one record format for each file).That
means 299 record format papers. 'Each paper containin( record format of a different file). If
the 3% /eeps all those 299 record format papers 'blue prints) in one file+ we can call that file
as C%ecord format fileD.
If we apply this formattin( concept to A7-899 physical files 'which stores data)+ definin( name+
type and len(th of a field is called field definition. If we define all fields and (ive a name to this
set of fields+ that name is called =%ecord format name=. The place where we store all record
formats of various files is called C7ource physical fileD 'E>uivalent to %ecord format file). It
contains record format details of each physical file. 7ource Physical file contains members.
$ne member contains record format details of one physical file.
E(* If we want to create a physical file record format for employee physical file+ we have to
first create a member in source physical file. Inside the member+ we must first (ive the name
of the record format. Then define name of each field+ its type and its len(th.
1efore that+ we need to learn various types of data available in A7-899.
A7899 Data Types* A for Character
P for Pac/ed Decimal
7 for Eoned Decimal
1 for 1inary
# for floatin( point
3 for heAadecimal
for date
T for time
E for timestamp
Fsin( above mentioned data types+ pro(rammers can define 'describe data) various fields in
a record format. 1esides (ivin( names to each field+ it is mandatory to (ive name to a record
format. These definitions are called Data Description 7pecifications. And record format details
of one physical file is called a DD7 member.
A typical Employee details record format in A7-899 is (iven below*
% E&P%EC#
Empname 599A
Empa(e 87 9
6ender 8A
7/ill 59A
Nationality 59A
Peraddr ?99A
Tempaddr ?99A
A pro(rammer can enter this source in a source physical file usin( 7ource Entry Ftility '7EF)
editor. After enterin( the source+ it should be saved and press #: to come out of the screen.
$nce the source is saved in a DD7 member+ one should compile the source in DD7 member
to create a memory location for the file to store data in the (iven format. $nly throu(h
compilin(+ the blue print transforms into an actual physical memory location with re>uired
format. '$ne can find details of 7EF+ how to enter source and compile from 6oo(le).
$ne should understand the difference between source file and physical file. 7ource file
contains the blue print of format details of a physical file. 1ut a physical file is actual formatted
memory location created usin( record format details in source physical file. 7o+ details of
record format in a source physical file is called =source codeD of a physical file in pro(rammer
.ar(on.
Compilin( a source code creates a physical file ob.ect 'table ob.ect). At the time of
compilation+ one has to mention how many records should be created in the file. If we don=t
mention+ 29/ records will be created by default. It means 29/ rows of data is allocated in the
mentioned si<e. 0e can enter data into that empty memory cells.
To enter data+ there are number of ways. 1ut the most basic way is enterin( data throu(h
Data #ile Ftility 'D#F). 6oo(le to find the details or refer I1& red boo/s.
Another feature offered by A7899 database physical file is =Data members=. If we (o bac/ to
our 3% eAample+ our 3% /eeps all employee forms in one file. Each form is one record. 7et of
records is file data. 1ut assume that we want to tie with thread all forms of employees who
.oined in 5998+ then 599;+ 599@...so on. 7o+ we se(re(ate forms 'forms means records which
means data) based on year. Now+ our 3% se(re(ates forms based on year and this will create
bunches of papers. Each bench contains records of employees .oined in a particular year. 1ut
we /eep all bunches in Employee file only. 1ut+ this is different from earlier stora(e. All papers
combined are called set of forms or set of records or set of data. 1ut each bunch 'based on
.oinin( year) is called sub"set of forms or subset of records or sub"set of data. The same way+
data is a database physical file can be se(re(ated based on field values. Each sub"set of
se(re(ated data is called =member= of that database physical file.
1ut actually when we compile our DD7 source member+ it creates a formatted physical file
ob.ect with empty records. 1ut+ all empty records constitute one member by default. This
member can be accessed by its name. 1y default the first member created by default
contains the same name as physical file name. All 29/ records will be allocated to this first
default member which has same name as physical file name. 0e can add more members to
a database physical file usin( CADDP#&D command. Please refer to I1& red boo/s on how to
use this command. There are various commands available in A7-899 to use various members
of a database physical file.
7o now we /now what a field is+ what a record format is+ what a physical file is+ what a data
member is and how to create a database physical file. $nce we create database physical file+
we can enter data.
Enterin( data does not actually end the story. It actually starts the whole story of
pro(rammin(. 1ecause the very purpose of enterin( data is to use it for later. The =use= word
covers a whole ran(e of activity li/e retrievin( data+ modifyin( data+ deletin( data etc.
et us first spea/ about a mechanism involved in retrievin( data.
Access Path 'or) IndeA* 0hen data is stored in a physical file+ it is stored in #I#$ order by
default. It means the first record that is stored will be the first record that will be retrieved
when file is accessed for data.
1ut the >uestion is+ how the $7-899 /nows what first record is and what is neAt record... so
onG
Apart from fields defined in a record format+ $7-899 adds another hidden field to each data
record in file. That field name is %elative %ecord Number '%%N H nothin( but a serial
number).
E(* A normal record format and data
Employee number Employee name Employee salary Employee 6rade
8;@?2 3arish /umar 2999999 IA
;@B:2 4usum 7hetty 2599999 I1
8III2 7andesh /apoor 29;9999 IA
%ecord format with %%N attached
%%N E&PN$ E&PNA&E E&P7A E&P6%ADE
2 8;@?2 3arish /umar 2999999 IA
5 ;@B:2 4usum 7hetty 2599999 I1
: 8III2 7andesh /apoor 29;9999 IA
%%N is a field that notes down which record arrived first and which record arrived neAt and so
on.... it notes down the se>uence number of each number in the manner of their arrival in to
the physical file.
That is how the $7-899 /nows the se>uence of arrival of records into file. 7o when records
are retrieved from a file+ the records are retrieved in the se>uence of their arrival. And hence
the name CArrival se>uence Access pathD. %%N is li/e the pa(e number in a boo/. The first
pa(e is opened first.
1ut what if you /now a word 'or topic headin( or concept in the boo/) and want to find its first
occurrence in the boo/ and second occurrence and so on...G
There is one conventional method. !ou read throu(h each word in each pa(e startin( from
pa(e one till the last pa(e and note down the se>uence of occurrence of the word you are
loo/in( for. This way you /now when the word first occurred and what pa(e numbers have
this word. 1ut it re>uires lot of effort.
Assume that you want to repeat the same procedure for same concept every day. $n top of
that assume you repeat this procedure to find out occurrences of various concepts+ headin(s
and topics etc. It consumes a lot of time and most the effort is un"necessary too. Then what is
the solutionG
$n the first attempt of this procedure+ it is wise to note down the occurrence se>uence+
perhaps in a piece of paper. Note down the occurrence of various topics pa(e wise or topic
wise. This is called indeAin(. !ou can see such indeAes at the end of each teAt boo/. In these
indeAes+ various topics discussed in a boo/ are (iven in alphabetical order with pa(e
numbers (iven for each topic. In this way+ you can (o to the pa(e number directly after findin(
the topic name which is (iven in indeA in alphabetical order.
7o+ one can eAplore the boo/ in two ways. Either via readin( each pa(e from pa(e 2 or
referrin( to indeA+ one can .ump to re>uired topic. 7o+ in the second way+ one need a topic
name and indeA. Topic name 'or) topic word is the /ey to eAplore the boo/ in second way.
This topic word can be called =4ey 0ord=.
7imilarly+ one may want to find a particular value 'column value) in a particular record 'row) of
a file. The column value is called the field and row is called record in A7-899 physical file.
A(ain+ we can read throu(h each record and value in the field of that record. If we apply the
indeAin( concept to physical files that will help to complete our search for data >uic/ly.
1ut there is a difference between applyin( indeAin( concept to a teAt boo/ and to an A7-899
physical file. In A7-899 physical file+ we only need to /now which record contains the least
value of a particular field and which record contains neAt least value... and so on. $r+ we only
need to /now which record contains the hi(hest value of a particular field and which record
contains neAt hi(hest value... and so on. The $7-899 will note down such se>uence if we tell
it to store such details.
1ut remember that li/e topic name or topic word in teAt boo/ indeAin(+ here in A7-899 field
name is the /ey to search its hi(hest or lowest value or any value. 7o+ when we tell to
$7-899+ it should maintain an indeA of values of a field either in ascendin( order or
descendin( order. 'Actually various other orders are also available).
#or E(*
Chec/ this table+ which is in arrival se>uence access path*
%%N E&PN$ E&PNA&E E&P7A E&P6%ADE
2 8;@?2 3arish /umar 2999999 IA
5 ;@B:2 4usum 7hetty 2599999 I1
: 8III2 7andesh /apoor 29;9999 IA
If we want an indeA of records based on employee number in ascendin( order. 3ere E&PN$
is the /ey field to create re>uired indeA.
3ere is how it loo/s when we create an indeA based on E&PN$ ascendin( *
%%N E&PN$ E&PNA&E E&P7A E&P6%ADE E&PN$*A7C
2 8;@?2 3arish /umar 2999999 IA %%N2*7EJ2
5 ;@B:2 4usum 7hetty 2599999 I1 %%N5*7EJ:
: 8III2 7andesh
/apoor
29;9999 IA %%N:*7EJ5
This se>uence filed is used when you want to retrieve the data in ascendin( se>uence of
E&PN$ field. This is retrievin( data in se>uence of /ey value. This is called 4eyed se>uence
in A7-899.
7o+ we now learn two A7-899 terms here+ Arrival se>uence access path and /eyed se>uence
access path. These terms spea/s of how data is retrieved from a file. If we want the records
in the same order which they were stored 'or) arrived into file+ that se>uence is called arrived
se>uence access path. 1ut+ we want records to be retrieved in the order of value of a /ey
field+ that se>uence is called /eyed se>uence access path.
Note* 0ithout an indeA eAistin( first+ one cannot retrieve the data usin( indeA. #or an indeA to
eAist before retrieval+ there are three ways to create an indeA. They are*
2) Declarin( a /ey field while writin( source for a physical field. This is permanent.
5) Creatin( a lo(ical file with /eyed se>uence access path on top of physical file. This also
Permanent.
:) 0hen neither the physical file nor the lo(ical file contains re>uired /eyed se>uence'it
means that either P# or # donKt have /eyed paths or they have /eyed se>uences based on
different /ey fields)+ one can temporarily create re>uired /eyed se>uence access path usin(
$verride database file and $pen >uery file commands. $pen >uery file command is powerful
utility that no serious application pro(rammin( is possible without usin( it.
Now let us understand the concept of =resources= of a database physical file. A file = resource=
simply means what the file =offers= for use to pro(rams and users. A file can (ive not only it=s
data but also its access path'indeA) details+ details of its ob.ect structure'maAimum number of
records it can store+ record format name+ field names+ field types and len(th+ names of /ey
fields+ it=s members etc.). 0ithout usin( all these resources+ no command or pro(ram can
access a database physical file.

Potrebbero piacerti anche