UNIHIVE

Study Hub UNIPORT CSC 283

CSC 283 · Information Systems and File Structures

From file systems to databases

The problems of separate files, how a database approach solves them, and how the file structures of this course live on inside databases.

Our notes

2 min read

Problems with separate file systems

In early systems each department kept its own files and programs:

  • Data redundancy: the same student's address in the bursary, the registry and the hostel files.
  • Inconsistency: the address changed in one file but not the others.
  • Program-data dependence: changing a record layout means changing every program that uses the file.
  • Poor sharing and security: each file has its own rules; combining data across departments is hard.
  • Integrity: rules (a result must belong to a registered student) are scattered through programs.

The database approach

A database is a single, shared, integrated collection of related data, managed by a database management system (DBMS) such as MySQL, PostgreSQL, Oracle or SQL Server.
The DBMS provides:

  • one definition of the data (the schema),
  • data independence (programs see logical tables, not physical files),
  • controlled sharing, security and integrity rules,
  • concurrency control (many users at once) and recovery (logs and backups),
  • a query language (SQL).

Inside a DBMS: the same structures

  • Tables are stored in pages (blocks) on disk, often 8 KB or 16 KB.
  • Indexes are B+ trees: the modern form of indexed sequential files.
  • Hash indexes and hash joins use hashing.
  • The transaction log is the dump-and-log recovery idea.
  • Buffer pools cache pages in memory.

So file structure knowledge explains why a query is slow (a full table scan instead of an index) and how to fix it.

Worked example: index or scan?

A results table has 2,000,000 rows, 50 rows per page, so 40,000 pages. A query wants one student's results (about 40 rows).

  • Full scan: read 40,000 pages.
  • B+ tree index on matric number of height 3, then the rows (assume they sit on about 40 different pages): about 3 + 40 = 43 page reads.

The index makes the query roughly a thousand times less work, which is why primary and foreign keys are indexed.

NoSQL and big data (in brief)

Key-value stores, document databases and distributed file systems (used for very large or fast-changing data) still rely on hashing, sorted files (log-structured merge trees) and blocking: the ideas of this course at a larger scale.

Exams usually ask

  • List the problems of traditional file systems and how a DBMS overcomes them.
  • Define data independence, redundancy and integrity.
  • Relate file organisations to the way a DBMS stores data.

Common mistake

Thinking files disappear in a database. A DBMS still stores everything in files on disk; it simply manages their structure for you.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All CSC 283 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.