Sei sulla pagina 1di 26

1.1.

INTRODUCTION TO FILE STRUCTURE


1.1.1. History

I. Early Work

 Early Work assumed that files were on tape.

 Access was sequential and the cost of acces grew in direct proportion to the size of the
file.

II. The emergence of Disks and Indexes

 As files grew very large, unaided sequential access was not a good solution.

 Disks allowed for direct access.

 Indexes made it possible to keep a list of keys and pointers in a small file that could
be searched very quickly.

 With the key and pointer, the user had direct access to the large, primary file.

III. The emergence of Tree Structures

 As indexes also have a sequential flavour, when they grew too much, they also
became difficult to manage.

 The idea of using tree structures to manage the index emerged in the early 60’s.

 However, trees can grow very unevenly as records are added and deleted, resulting in
long searches requiring many disk accesses to find a record.

IV. Balanced Trees

 In 1963, researchers came up with the idea of AVL trees for data in memory.

 AVL trees, however, did not apply to files because they work well when tree nodes
are composed of single records rather than dozens or hundreds of them.

 In the 1970’s came the idea of B-Trees which require an O(logk N) access time where
N is the number of entries in the file and k, th number of entries indexed in a single
block of the B-Tree structure --> B-Trees can guarantee that one can find one file
entry among millions of others with only 3 or 4 trips to the disk.

V. Hash Tables

 Retrieving entries in 3 or 4 accesses is good, but it does not reach the goal of
accessing data with a single request.

 From early on, Hashing was a good way to reach this goal with files that do not
change size greatly over time.

 Recently, Extendible Dynamic Hashing guarantees one or at most two disk accesses
no matter how big a file becomes.

Program Disk file

key key key

record record Index Data

Fig 1.1: Organisation of File Structures

File structures is the organisation of data in secondary storage device in such a way that
minimize the access time and the storage space.

A file structure is a combination of representations for data in files and of operations for
accessing the data.

A file structure allows applications to read,write and modify data. It might also support
finding the data that matches some search criteria or reading through the data in some
particular order.

Computer data can be stored in 3 kinds of loactions:


Primary storagememory[computer memory]

Secondary storage[online disk/tape/cdrom that can be accessed by the computer]

Ternary storagearchival data[offline disk/tape/cdrom directly not available to the


computer]

Secondary storage such as disks can pack thousands of megabytes in a small physical
location. Computer Memory (RAM) is limited. However, relative to Memory, access to
secondary storage is extremely slow [E.g., getting information from slow RAM takes 120.
10-9 seconds (= 120 nanoseconds) while getting information from Disk takes 30. 10-3
seconds (= 30 milliseconds)]

1.1.2 About the Files

Files exist to store information and allow it to be retrieved later. Different systems provide
different
Operations to allow storage and retrieval. Below is a discussion of the most common system
calls
relating to files.

1. Create.
The file is created with no data. The purpose of the call is to announce that the file is
coming and to set some of the attributes.

2. Delete
. When the file is no longer needed, it has to be deleted to free up disk space. A system
call for this purpose is always provided.

3. Open.
Before using a file, a process must open it. The purpose of the open call is to allow the
system to fetch the attributes and list of disk addresses into main memory for rapid access on
later calls.

4. Close.
When all the accesses are finished, the attributes and disk addresses are no longer
needed, so the file should be closed to free up some internal table space. Many systems
encourage this by imposing a maximum number of open files on processes. A disk is written
in
blocks, and closing a file forces writing of the file's last block, even though that block may
not
be entirely full yet.
5. Read.
Data are read from file. Usually, the bytes come from the current position. The caller
must specify how much data are needed and must also provide a buffer to put them in.

6. Write.
Data are written to the file, again, usually at the current position. If the current position
is the end of the file, the file's size increases. If the current position is in the middle of the file,
existing data are overwritten and lost forever.

7. Append.
This call is a restricted form of write. It can only add data to the end of the file.
Systems that provide a minimal set of system calls do not generally have append, but many
systems provide multiple ways of doing the same thing, and these systems sometimes have
append.

8. Seek
. For random access files, a method is needed to specify from where to take the data. One
common approach is a system call, seek, that repositions the file pointer to a specific place in
the file. After this call has completed, data can be read from, or written to, that position.

9. Get attributes
. Processes often need to read file attributes to do their work. For example, the
UNIX make program is commonly used to manage software development projects consisting
of
many source files. When make is called, it examines the modification times of all the source
and object files and arranges for the minimum number of compilations required to bring
everything up to date. To do its job, it must look at the attributes, namely, the modification
times.

10. Set attributes.


Some of the attributes are user settable and can be changed after the file has
been created. This system call makes that possible. The protection mode information is an
obvious example. Most of the flags also fall in this category.

11. Rename.
It frequently happens that a user needs to change the name of an existing file. This
system call makes that possible. It is not always strictly necessary, because the file can
usually
be copied to a new file with the new name, and the old file then deleted.

12.Lock.
Locking a file or a part of a file prevents multiple simultaneous access by different process.
1.1.3 Various Storage Kind of Fields and Records

Sequential files

A sequential file is the most primitive of all file structures. It has no directory and no linking
pointers. The records are generally organised in lexicographic order on the value of some
key. In other words, a particular attribute is chosen whose value will determine the order of
the records. Sometimes when the attribute value is constant for a large number of records a
second key is chosen to give an order when the first key fails to discriminate.

The implementation of this file structure requires the use of a sorting routine.

Its main advantages are:

(1) it is easy to implement;

(2) it provides fast access to the next record using lexicographic order.

Its disadvantages:

(1) it is difficult to update - inserting a new record may require moving a large proportion of
the file;

(2) random access is extremely slow.

Index-sequential files

An index-sequential file is an inverted file in which for every keyword Ki , we have ni = hi =


1 and a11 <a21 . . . <am1. This situation can only arise if each record has just one unique
keyword, or one unique attribute-value. In practice therefore, this set of records may be order
sequentially by a key. Each key value appears in the directory with the associated address of
its record. An obvious interpretation of a key of this kind would be the record number. In our
example none of the attributes would do the job except the record number. Diagrammatically
the index-sequential file would therefore appear as shown in Figure 4.4. I have deliberately
written Ri instead of Ki to emphasise the nature of the key.
In the literature an index-sequential file is usually thought of as a sequential file with a
hierarchy of indices. This does not contradict the previous definition, it merely describes the
way in which the directory is implemented. It is not surprising therefore that the indexes
('index' = 'directory' here) are often oriented to the characteristics of the storage medium. For
example (see Figure 4.5) there might be three levels of indexing: track, cylinder and master.
Each entry in the track index will contain enough information to locate the start of the track,
and the key of the last record in the track which is also normally the highest value on that
track. There is a track index for each cylinder. Each entry in the cylinder index gives the last
record on each cylinder and the address of the track index for that cylinder. If the cylinder
index itself is stored on tracks, then the master index will give the highest key referenced for
each track of the cylinder index and the starting address of that track.

Variable length Record


Variable length refers to anything whose length can vary. For example, in databases, a variable-length
field is a field that does not have a fixed length. Instead, the field length varies depending on what
data is stored in it.

Fixed length Record

Fixed length means having a set length that never varies. In database systems, a field can
have a fixed or a variable length. A variable-length field is one whose length can be different
in each record, depending on what data is stored in the field.

The terms fixed length and variable length can also refer to the entire record. A fixed-length
record is one in which every field has a fixed length. A variable-length record has at least one
variable-length field

1.1.4Applications of file structures:

1. Backup:

 It is possible to take faster and automatic back-up of database stored in files of


computer-based systems.
 computer systems provide functionalities to serve this purpose.it is also possible to
develop specific application program for this purpose.

2. Compactness:

 It is possible to store data compactly.

3. Data Retrieval:

 Computer-based systems provide enhanced data retrieval techniques to retrieve data


stored in files in easy and efficient way.

4. Editing:

 It is easy to edit any information stored in computers in form of files.


 Specific application programs or editing software can be used for this purpose.

5. Remote Access:

 In computer-based systems,it is possible to access data remotely.


 so,to access data it is not necessary for a user to remain present at location where
these data are kept.
6. Sharing:

 Data stored in files of computer-based systems can be shared among multiple users at
a same time.

CHAPTER 2.
System Analysis

2.1 Analysis of Application

The Traditional way of maintaining details of a user in a bank was to enter the detail and
record them. Every time the user needs to perform some transactions he has to go to bank and
perform the necessary actions, which may not be so feasible all the time. It may be a hard-
hitting task for the users and the bankers too. The project gives real life understanding of
offline Banking System and activities performed by various roles in the supply chain. Here,
we provide automation for banking system through offline. Offline Banking System project
captures activities performed by different roles in real life banking which provides enhanced
techniques for maintaining the required information up-to-date, which results in efficiency.
The project gives real life understanding of Offline Banking Management System and
activities performed by various roles in the supply chain.

2.2 Structure used to Store the Fields and Records

Sequential File
A very natural way to store a file is in the form of an array, or a linked list of the records.
In these representations, the entire file may be traversed in a linear fashion. This file structure
is called sequential file. It is simple to implement and can be economic in space.
On the negative side, most search operations in such a file are likely to be inefficient, since
searching requires traversing of the sequence of records according to the storage sequence. In
case of large files, particularly when the file is in disk, such traversal times can be too long. If
the structure used is an array (and not a linked list), and the records are of equal sizes, then
searching can be made efficient by keeping the records sorted on one key field. In that case
searching based on that key field can be carried out using binary search. But search based on
any other field value cannot derive the benefit of binary search. Moreover, using an array for
storing a file makes growth or shrinking of the file (due to insertions and deletions)
inconvenient. To overcome this one may use some kind of search tree structure to store
records instead of a simple sequential structure.
2.3 Operation Performed on a File

File Input/Output in C
A file represents a sequence of bytes on the disk where a group of related data is stored. File
is created for permanent storage of data. It is a ready made structure.
In C language, we use a structure pointer of file type to declare a file.
FILE *fp;
C provides a number of functions that helps to perform basic file operations. Following are
the functions,
Function description
fopen() create a new file or open a existing file
fclose() closes a file
getc() reads a character from a file
putc() writes a character to a file
fscanf() reads a set of data from a file
fprintf() writes a set of data to a file
getw() reads a integer from a file
putw() writes a integer to a file
fseek() set the position to desire point
ftell() gives current position in the file
rewind() set the position to the begining point
________________________________________
Opening a File or Creating a File
The fopen() function is used to create a new file or to open an existing file.
General Syntax:
*fp = FILE *fopen(const char *filename, const char *mode);
Here, *fp is the FILE pointer (FILE *fp), which will hold the reference to the opened(or
created) file.
filename is the name of the file to be opened and mode specifies the purpose of opening the
file. Mode can be of following types,
mode description
R opens a text file in reading mode
W opens or create a text file in writing mode.
A opens a text file in append mode
r+ opens a text file in both reading and writing mode
w+ opens a text file in both reading and writing mode
a+ opens a text file in both reading and writing mode
Rb opens a binary file in reading mode
Wb opens or create a binary file in writing mode
Ab opens a binary file in append mode
rb+ opens a binary file in both reading and writing mode
wb+ opens a binary file in both reading and writing mode
ab+ opens a binary file in both reading and writing mode
________________________________________
Closing a File
The fclose() function is used to close an already opened file.

2.4 Indexing Used

Indexed Sequential File


Overcome the shortcomings of the sequential file structures, indexed sequential file structure
is used. In this the records of the file are stored like in a sequential file. But in addition to this,
some index of the records is (are) maintained. An index is a collection of (key_value,
record_address) pairs. The index is represented using a separate data structure. A search for a
record using a key field shall now be carried out in the index based on that key value. Once
the index entry is located, the record_address part of the entry can be used to directly access
the record. Due to smaller size of the index, it can be structured in a way that facilitates
efficient search, eg. sorted array (for binary search), hash table, search-trees, etc. Also, for the
same file several indexes using different key field can be maintained to help search based on
different key fields. Since an index can contain many entries (as many as the number of
records in the file), structuring them appropriately to facilitate an efficient search is important

CHAPTER 3
SYSTEM DESIGN

3.1. User Interface:

3.1.1. Insertion:
- In our Student Transportation management system we are having following insertion as
follows,

1. Name
2. Father name
3. Phone number
4. Address
5. Profession
6. Seat number
7. Username
8. Password

3.1.2. Display:
In our Student Transportation management system we are having following Display of
record,
1. Name
2. Father name
3. Phone number
4. Address
5. Profession
6. Seat no
7. Total Fee amount

3.1.3. Search:
In our Student Transportation management System we have the following Search record,
1. Enter the username:

Chapter 4: Implementation

4.1 About C++:


C++ is a general-purpose object-oriented programming (OOP) language, developed by
Bjarne Stroustrup, and is an extension of the C language. It is therefore possible to code C++
in a "C style" or "object-oriented style." In certain scenarios, it can be coded in either way
and is thus an effective example of a hybrid language.

C++ is considered to be an intermediate-level language, as it encapsulates both high- and


low-level language features. Initially, the language was called "C with classes" as it had all
the properties of the C language with an additional concept of "classes." However, it was
renamed C++ in 1983.

It is pronounced "see-plus-plus."
C++ is one of the most popular languages primarily utilized with system/application
software, drivers, client-server applications and embedded firmware.

The main highlight of C++ is a collection of predefined classes, which are data types that can
be instantiated multiple times. The language also facilitates declaration of user-defined
classes. Classes can further accommodate member functions to implement specific
functionality. Multiple objects of a particular class can be defined to implement the functions
within the class. Objects can be defined as instances created at run time. These classes can
also be inherited by other new classes which take in the public and protected functionalities
by default.

C++ includes several operators such as comparison, arithmetic, bit manipulation and logical
operators. One of the most attractive features of C++ is that it enables the overloading of
certain operators such as addition.
A few of the essential concepts within the C++ programming language include
polymorphism, virtual and friend functions, templates, namespaces and pointers.

4.2 Pseudocode

4.2.1 Insertion Module Pseudo code:

int register_now::registration_form()

string password;

char pwd[7];

int i=0;

system("cls");

a++;

fstream fil5;

fil5.open("login.txt",ios::out|ios::app);

cout<<" \n";

char b[]="REGISTRATION FORM\n";

int x=strlen(b);

for(int i=0;i<x;i++)

Sleep(25);

cout<<b[i];

cout<<endl<<endl<<setw(5)<<"NAME :";

cin>>name[0];

cout<<endl<<setw(40)<<"FATHER NAME :";

cin>>name[1];
cout<<endl<<setw(5)<<"Ph_no:";

cin>>name[2];

cout<<endl<<setw(35)<<"ADDRESS:";

cin>>name[3];

cout<<endl<<setw(10)<<"PROFESSION:";

cin>>name[4];

cout<<endl<<setw(5)<<"Select seat Number: \n"<<endl;

int count=1;

for(int i=0;i<10;i++)

for(int j=0;j<5;j++)

if(j==3)

cout<<" ";

}cout<<setw(4)<<count<<" ";count++;

cout<<endl;

cout<<" ";

for(int i=51;i<=60;i++)

cout<<setw(3)<<i;

string user4;

cout<<": ";

cin>>name[5];

cout<<"\n staff or student:";


cin>>user4;

if(user4=="student"||"STUDENT")

cout<<endl<<endl<<"Your username :";

cin>>name[6]; //<<a;

cout<<endl<<"PASSWORD :";

while(i<6)

pwd[i]=getch();

putchar('*');

++i;

password=pwd;

fil5<<name[6]; //<<a;

fil5<<password<<"\n";

name[7]="17000";

cout<<name[7];

fil5.close();

fstream fil2;

fil2.open("list_of_students.txt",ios::in | ios::out | ios::app);

fil2.seekg(74);

fil2<<" ";

//fil2.setf(ios::left,ios::adjustfield);

for(int i=0;i<6;i++)

fil2.setf(ios::left,ios::adjustfield);

fil2<<setw(20)<<name[i];

count++;
}

fil2<<endl;

Sleep(600);

else

if(user4=="staff"||"STAFF")

cout<<endl<<endl<<"Your username :";

cout<<name[6];

cout<<endl<<"PASSWORD :";

while(i<6)

pwd[i]=getch();

putchar('*');

++i;

password=pwd;

fil5<<name[6];

fil5<<password<<"\n";

name[7]="17000";

cout<<name[7];

fil5.close();

fstream fil2;

fil2.open("list_of_students.txt",ios::in | ios::out | ios::app);

fil2.seekg(74);

fil2<<name[5];

//fil2.setf(ios::left,ios::adjustfield);
for(int i=0;i<6;i++)

fil2.setf(ios::left,ios::adjustfield);

fil2<<setw(20)<<name[i];

count++;

fil2<<endl;

Sleep(600);

4.2.2 Display Module Pseudo code:

int main()

char ch;

system("COLOR 2C");

while(1)

system("cls");

cout<<endl<<endl;

fstream f2;

f2.open("sysmbol.txt",ios::in);

while(f2)

f2.get(ch);

cout<<ch;
}

Sleep(1000);

system("COLOR 8F");

char a[]=" $$$$$$$$$$$ SAIT STMS WELCOMES YOU $$$$$$$$$$$";

int size;

size=strlen(a);

for(int i=0;i<size;i++)

Sleep(25);

cout<<a[i];

int c=1;

cout<<endl<<endl;

Sleep(0);

cout<<"\n 1.REGISTER NOW \n 2.STAFF LOGIN \n


3.STUDENT LOGIN \n"

<<" 4.NOTICES\n 5.EXIT";

for(int i=0;i<1;i++)

int x = 16;

int y = 10;

for (y=10;y<19;y++)

gotoXY(x,y);

cout << "*";

Sleep(100);

// gotoXY(x,y);

// cout << " ";

}
y=19;

for (x=16;x<63;x++)

gotoXY(x,y);

cout << "*";

Sleep(20);

// gotoXY(x,y);

// cout << " ";

for (y=10;y<20;y++)

gotoXY(x,y);

cout << "*";

Sleep(100);

// gotoXY(x,y);

// cout << " ";

register_now r1;

staff_login s1;

student_login s2;

int ch;

cout<<"\nSelect your option :";

cin>>ch;

fstream f1;

switch(ch)

{
case 1:system("COLOR 1F");

r1.instructionsform();

break;

case 2:system("COLOR 1F");

s1.login();

break;

case 3:system("COLOR 1F");

s2.login();

break;

case 4:system("COLOR 1F");

r1.notice();

break;

default:exit(0);

break;

getch();

return 0;

4.2.3 Search Module Pseudo code:

int student_login::allotmentform()

system("cls");

string j,tem[10];
int i,d;

cout<<"Enter your Username :";

cin>>j;

ifstream f8;

f8.open("list_of_students.txt",ios::in);

f8.seekg(0,ios::beg);

while(!f8.eof())

i++;

string temp;

f8 >> temp;

if(temp == j)

d=f8.tellg();

break;

int y=d+6;

int l=0;

while(d!=y)

d++;

string temp;

f8>>temp;

tem[l]=temp;

l++;

system("cls");
cout.setf(ios::left,ios::adjustfield);

cout<<endl<<endl<<" NAME :"<<j;

cout<<endl<<endl<<" FATHER NAME :"<<tem[0];

cout<<endl<<endl<<" Ph_no :"<<tem[1];

cout<<endl<<endl<<" ADDRESS :"<<tem[2];

cout<<endl<<endl<<"\n\n PROFESSION :"<<tem[3];

cout<<endl<<endl<<" Alloted seat Number :"<<tem[4];

cout<<endl<<endl<<endl<<"\n Total amount DUE : Rs 17000"<<tem[5]<<"|-


"<<endl<<endl

<<" staff/student sign\n";

cout<<"Enter any key to retun back to menu :";

getch();

return 1;

4.3 Testing
4.3.1 ACCEPTANCE TESTING is a level of software testing where a system is tested for acceptability.
The purpose of this test is to evaluate the system’s compliance with the business requirements and
assess whether it is acceptable for delivery.

4.3.2 SYSTEM TESTING is a level of software testing where complete and integrated software is
tested. The purpose of this test is to evaluate the system’s compliance with the specified
requirements. The process of testing an integrated system to verify that it meets specified
requirements.

4.3.3 Integration testing (sometimes called integration and testing, abbreviated I&T) is the
phase in software testing in which individual software modules are combined and tested as a
group. It occurs after unit testing and before validation testing. Integration testing takes as its
input modules that have been unit tested, groups them in larger aggregates, applies tests
defined in an integration test plan to those aggregates, and delivers as its output the integrated
system ready for system testing.[1]

4.3.4 System testing is an investigation conducted to provide stakeholders with information


about the quality of the software product or service under test.[1] Software testing can also
provide an objective, independent view of the software to allow the business to appreciate
and understand the risks of software implementation. Test techniques include the process of
executing a program or application with the intent of finding software bugs (errors or other
defects), and verifying that the software product is fit for use.

Software testing involves the execution of a software component or system component to


evaluate one or more properties of interest. In general, these properties indicate the extent to
which the component or system under test

 meets the requirements that guided its design and development,


 responds correctly to all kinds of inputs,
 performs its functions within an acceptable time,
 is sufficiently usable,
 can be installed and run in its intended environments, and
 Achieves the general result its stakeholder’s desire.

4.4 Discussion of results:

4.4.1 Menu
4.4.2 Insertion
4.4.3 Searching a record:

CHAPTER 5

CONCLUSION AND FUTURE ENHANVEMENTS:


The student transportation management project was initiated to explore efficiencies resulting from
the implementation of computerized routes in school transportation, and to identify opportunities
for coordinated transportation in the education community. Given their shared characteristics, the
routing algorithm used to study the selected districts routes shows promise of being able to provide
solutions to transportation providers. A routing algorithm was used to estimate the impacts of
changes in school policy regarding the number of routes and the location of housing for district
vehicles. It was also used to identify the near-optimal service for the institution.

There are opportunities for increased efficiency from using computerized routing tools in rural
school districts. Although the routes produced by the study have not been put into effect as of the
time of the publication of this report, significant improvements in efficiency were identified. Given
the challenges, it is likely that a formal introduction of computerized routing techniques and
increased levels of coordination will occur in the coming years.

FUTURE ENCHANCEMENTS:

The “Student Transportation Management System” is a big and ambitious project. I am thankful for
being provided this great opportunity to work on it. As already mentioned, this project has gone
through extensive research work. On the basis of the research work, we have successfully designed
and implemented Student Transportation Management System. To know what the future of Student
Transportation looks like, it’s probably worth looking at the present – Student Transportation isn’t
new. When you think of Student Transportation, you probably think about a computer (either a
desktop or laptop), a three or four step security process and then an interface that lets you view the
routes and information of all the students and staff memebers travelling. The Student Transpotation
Management has a better future obviously because it is better than the manual way of handling the
records.

Developed by Ruchitha B[B.E],Sowmya K L[B.E],Akshata J A[B.E]

REFERENCES:

Anderle, S.J., D.A. Kroeger, and J. Mascarello. 2005. Coordination of Transit and School Busing in
Iowa. Iowa Department of Transportation.

Baltes, M.R. 2001. Opportunities for the Coordination of General Public Transit and School Bus
Transportation.

Tampa, FL: Center for Urban Transportation Research. Burckhardt, J.E., D. Koffman, and G. Murray.
2003. Economic Benefits of Coordinating Human Service Transportation and Transit Services. TCRP
Report 91. Washington, D.C.: Transit Cooperative Research Program.

Potrebbero piacerti anche