Informatics Practices · Ch 6 — Database Concepts
File System
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:
| RollNumber | SName | SDateofBirth | GName | GPhone | GAddress |
|---|---|---|---|---|---|
| 1 | Atharv Ahuja | 2003-05-15 | Amit Ahuja | 5711492685 | G-35, Ashok Vihar, Delhi |
| 2 | Daizy Bhutia | 2002-02-28 | Baichung Bhutia | 3612967082 | Flat no. 5, Darjeeling Appt., Shimla |
| 3 | Taleem Shah | 2002-02-28 | Himanshu Shah | 4726309212 | 26/77, West Patel Nagar, Ahmedabad |
| 4 | John Dsouza | 2003-08-18 | Danny Dsouza | S-13, Ashok Village, Daman | |
| 5 | Ali Shah | 2003-07-05 | Himanshu Shah | 4726309212 | 26/77, West Patel Nagar, Ahmedabad |
| 6 | Manika P. | 2002-03-10 | Sujata P. | 3801923168 | HNO-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. …
| RollNumber | SName | SDateofBirth | GName | GPhone | GAddress |
|---|---|---|---|---|---|
| 1 | Atharv Ahuja | 2003-05-15 | Amit Ahuja | 5711492685 | G-35, Ashok Vihar, Delhi |
| 2 | Daizy Bhutia | 2002-02-28 | Baichung Bhutia | 3612967082 | Flat no. 5, Darjeeling Appt., Shimla |
| 3 | Taleem Shah | 2002-02-28 | Himanshu Shah | 4726309212 | 26/77, West Patel Nagar, Ahmedabad |
| 4 | John Dsouza | 2003-08-18 | Danny Dsouza | S -13, Ashok Village, Daman |
| AttendanceDate | RollNumber | SName | AttendanceStatus |
|---|---|---|---|
| 2018-09-01 | 1 | Atharv Ahuja | P |
| 2018-09-01 | 2 | Daizy Bhutia | P |
| 2018-09-01 | 3 | Taleem Shah | A |
| 2018-09-01 | 4 | John Dsouza | P |
| 2018-09-01 | 5 | Ali Shah | A |
| 2018-09-01 | 6 | Manika P. | P |
| 2018-09-02 | 1 | Atharv Ahuja | P |
| 2018-09-02 | 2 | Daizy Bhutia | P |
| 2018-09-02 | 3 | Taleem Shah | A |