A file is a named collection of related data stored on secondary storage (e.g., hard drive, SSD). In programming, files are used to store data persistently — data that survives when the program ends.
OPEN("file.txt", "r") — open for readingOPEN("file.txt", "w") — open for writing (overwrites)OPEN("file.txt", "a") — open for appendingREAD(fileHandle, data) — read from fileWRITE(fileHandle, data) — write to fileCLOSE(fileHandle) — close fileEOF(fileHandle) — check if at end of fileA database is an organised collection of structured data, typically stored in tables. A relational database uses multiple tables linked by relationships.
| Students table | Courses table | |
|---|---|---|
| studentID (PK) | → | courseID (PK) |
| name | courseName | |
| courseID (FK) | teacherName |
SQL (Structured Query Language) is used to query and manipulate relational databases:
SELECT name, grade FROM Students WHERE grade > 70;SELECT * FROM Students ORDER BY name;INSERT INTO Students VALUES (101, 'Aisha', 85);UPDATE Students SET grade = 90 WHERE studentID = 101;DELETE FROM Students WHERE studentID = 101;| Feature | Flat file | Database |
|---|---|---|
| Data organisation | Single file, no relationships | Multiple linked tables |
| Searching | Must read whole file | Efficient queries (SQL) |
| Redundancy | Data often duplicated | Reduced via normalisation |
| Multi-user | Poor | Designed for concurrent access |
8 Edexcel-style questions · AI-marked
| Term | Definition |
|---|
Timed exam-style test.