CSC 282 · Database Programming
Our notes
2 min readThe data hierarchy
bit → byte (character) → field → record → file → database.
- Field: one item of data about something: Surname, MatricNo, CGPA.
- Record: all the fields about one thing: one student.
- File: a collection of records of the same kind: all students.
- Database: related files (students, courses, results) managed together.
Field types
| Type | Example | Notes |
|---|---|---|
| text (character) | Surname "Okoro" | fixed or variable length |
| integer | Level 200 | no decimals |
| decimal / currency | Fees 85000.00 | exact money values |
| date / time | DateOfBirth | allows date arithmetic |
| Boolean | Hostel yes/no |
Choose the type that matches how the field is used: phone numbers are text, not numbers (a leading 0 must stay, and you never add them).
Keys
- Primary key: a field (or fields) that identifies each record uniquely: MatricNo.
- Secondary key: a field used to search or sort that need not be unique: Department.
- Foreign key: a field that refers to the primary key of another file (CourseCode in a results file).
Fixed and variable length records
- Fixed length: every record takes the same space (e.g. 100 bytes). The position of record n is (n − 1) × 100: easy direct access, but space is wasted on short names.
- Variable length: records take only what they need, with separators or a length count; saves space but you cannot jump straight to record n.
Kinds of files
- Master file: permanent data, updated periodically.
- Transaction file: changes waiting to be applied.
- Reference (table) file: lookup data that rarely changes (course titles, fee rates).
- Archive / backup file: old copies kept for recovery and history.
- Log file: a record of what was done, by whom and when.
Example record layout
| Field | Type | Size |
|---|---|---|
| MatricNo | text | 13 |
| Surname | text | 30 |
| OtherNames | text | 40 |
| Level | integer | 3 |
| CGPA | decimal | 4,2 |
Fixed record length = 13 + 30 + 40 + 3 + 4 = 90 characters (if numbers are stored as text). A file of 12,000 students takes 12,000 × 90 = 1,080,000 bytes, about 1 MB.
Exams usually ask
- Define field, record, file and key with examples.
- Draw a record layout and work out file size.
- Explain master, transaction and reference files.
Common mistake
Using a name as the primary key. Two students can share a name; a key must be unique and should not change.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Best pick Field (computer science)
(opens en.wikipedia.org in a new tab)
Wikipedia, Field (computer science), CC BY-SA 4.0 · licence
-
Record (computer science)
(opens en.wikipedia.org in a new tab)
Wikipedia, Record (computer science), CC BY-SA 4.0 · licence
-
Computer file
(opens en.wikipedia.org in a new tab)
Wikipedia, Computer file, CC BY-SA 4.0 · licence
-
NOUN CIT 304: Data Management
NOUN course book (PDF, about 6.9 MB: best on Wi-Fi). Files, databases, the relational model and SQL.
(opens nou.edu.ng in a new tab)
-
NOUN CIT 213: Elementary Data Processing
NOUN course book (PDF, about 0.9 MB). Fields, records, files and processing data.
(opens nou.edu.ng in a new tab)
Watch
-
Defination of fields,records and files | DBMS | LK World
3 min · ≈ 14 MB · about ₦8
(opens youtube.com in a new tab)
-
1. Database Basics: Understanding Definitions, Tables, Fields, and Records with Primary Key.
13 min · ≈ 59 MB · about ₦33
(opens youtube.com in a new tab)
-
What is a Field, Record, and File? Difference between Field, record, file| DBMS |Greencs217
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
Introduction to databases - What is a database? FIELDS RECORDS TABLES KEY FIELD- VIDEO 1 of 3
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
Database Introduction, Entities, Tables, Fields and Records.
1 h 38 min · ≈ 441 MB · about ₦248
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.