01 TRANSCRIPT-RECORD.
02 STUDENT-ID-NUMBER PICTURE X(9).
02 STUDENT-NAME PICTURE X(25).
02 COURSES-TAKEN-ARRAY.
03 COURSE-TAKEN OCCURS 50 TIMES.
04 SEMESTER-CODE PIC X(4).
04 COURSE-ID-NUMBER PIC X(5).
04 FINAL-GRADE PIC X(1).
|
In this first example each student has a transcript record that includes the student’s ID number and name, plus an array that allows space for 50 courses. For each of the courses the semester code, course ID number, and final grade are recorded. The record takes up exactly 534 bytes. There are 34 bytes for the student number and name plus 10 bytes for each of the 50 courses. (50 times 10, plus 34 is 534.) The nine character student ID number could be used as a unique key for this record. |
|
|
|
01 TRANSCRIPT-RECORD. 02 STUDENT-ID-NUMBER PIC X(9). 02 STUDENT-NAME PIC X(25). 02 SEMESTER-CODE PIC X(4). 02 COURSE-ID-NUMBER PIC X(5). 02 FINAL-GRADE PIC X(1). |
In this example we remove the array. The record still includes the student’s ID number and name. There is now room for one course which again consists of the semester code, course number, and final grade. This record consists of 44 bytes but can only hold one course. If a student takes multiple courses then multiple transcript records will be needed. If a student takes ten courses then there will be a total of 10 transcript records, for a total of 440 bytes. If a student takes 50 courses then 50 records will be needed, for a total of 2,200 bytes. The student ID number alone is no longer a unique key within the file. However, the student ID number plus the semester code and course number would constitute a unique key. |
|
|
|
01 TRANSCRIPT-RECORD. 02 STUDENT-ID-NUMBER PIC X(9). 02 SEMESTER-CODE PIC X(4). 02 COURSE-ID-NUMBER PIC X(5). 02 FINAL-GRADE PIC X(1). 01 STUDENT-RECORD. 02 STUDENT-ID-NUMBER PIC X(9). 02 STUDENT-NAME PIC X(25). |
We can eliminate the repetition of the student’s name in each record. If the name was stored in a separate student record it would only have to be stored once. The student ID number would serve as a common key between the transcript file and the student file. This reduces the transcript record to 19 bytes. A student taking 50 courses would need 50 transcript records, for a total of 950 bytes in the transcript file. |