Skip to content

Informatics Practices · Ch 6 — Database Concepts

File System

6.2

File System

Every program that shows you information — a report on a website, a bill at a shop counter — has to read that information from somewhere on the computer. The traditional answer to "where" is the file. A file is best understood as a container for storing data, kept on the storage device of a computer system. Anything the computer works with can sit inside a file: plain text, computer program code, comma separated values (CSV), and just as much the pictures, audios, videos and web pages you use every day — each of these is a file too.

Files stored on a computer can be accessed directly, and a person can open one and search it for the data they want. The difficulty begins when data in a file has to be reached through software rather than by a human reader. Suppose a school wants to display the monthly attendance report on its website. The website cannot simply "look at" the file the way a person does — someone has to write a computer program that opens the file, reads its contents and extracts the required data. In a file-based setup, every such need means writing a program.

The school attendance example

To make this concrete, consider how a school would keep attendance data using files. The data about students and their attendance is stored in two separate files.

The STUDENT file, maintained by the office staff, has six columns:

  • RollNumber — roll number of the student
  • SName — name of the student
  • SDateofBirth — date of birth of the student
  • GName — name of the student's guardian
  • GPhone — phone number of the guardian
  • GAddress — address of the guardian

Its contents (Table 7.1) look like this:

RollNumberSNameSDateofBirthGNameGPhoneGAddress
1Atharv Ahuja2003-05-15Amit Ahuja5711492685G-35, Ashok Vihar, Delhi
2Daizy Bhutia2002-02-28Baichung Bhutia3612967082Flat no. 5, Darjeeling Appt., Shimla
3Taleem Shah2002-02-28Himanshu Shah472630921226/77, West Patel Nagar, Ahmedabad
4John Dsouza2003-08-18Danny DsouzaS-13, Ashok Village, Daman
5Ali Shah2003-07-05Himanshu Shah472630921226/77, West Patel Nagar, Ahmedabad
6Manika P.2002-03-10Sujata P.3801923168HNO-13, B-block, Preet Vihar, Madurai

The ATTENDANCE file, maintained by the class teacher, has four columns:

  • AttendanceDate — the date for which attendance was marked
  • RollNumber — roll number of the student
  • SName — name of the student
  • AttendanceStatus — marked as P (present) or A (absent)

For each working day the teacher adds one row per student, so for two dates — 2018-09-01 and 2018-09-02 — the file holds twelve rows, one for each of the six students on each date. …

Table 7.1STUDENT file maintained by office staff
RollNumberSNameSDateofBirthGNameGPhoneGAddress
1Atharv Ahuja2003-05-15Amit Ahuja5711492685G-35, Ashok Vihar, Delhi
2Daizy Bhutia2002-02-28Baichung Bhutia3612967082Flat no. 5, Darjeeling Appt., Shimla
3Taleem Shah2002-02-28Himanshu Shah472630921226/77, West Patel Nagar, Ahmedabad
4John Dsouza2003-08-18Danny DsouzaS -13, Ashok Village, Daman
Table 7.2ATTENDANCE file maintained by class teacher
AttendanceDateRollNumberSNameAttendanceStatus
2018-09-011Atharv AhujaP
2018-09-012Daizy BhutiaP
2018-09-013Taleem ShahA
2018-09-014John DsouzaP
2018-09-015Ali ShahA
2018-09-016Manika P.P
2018-09-021Atharv AhujaP
2018-09-022Daizy BhutiaP
2018-09-023Taleem ShahA