Relational Databases
What is a database?
- A Database is a structured, persistent collection of data
- It allows easy storage, retrieval, and management of information
- Electronic databases offer a number of key benefits:
- Easier to add, delete, modify and update data
- Data can be backed up and copied easier
- Multiple users, from multiple locations, can access the same database at the same time
- There are two main types of database
- Flat file
- Relational
Flat file database
- A flat file database is one that stores all data in a single table
- It is simple and easy to understand but causes data redundancy, inefficient storage and is harder to maintain
-
Consider this example flat file table of students
- This table has redundant data - the tutor and form room information repeats, this is inefficient
- If a tutor changed their name we would need to find all instances of that name and change them all
- Missing any would mean the table had inconsistent data
Relational database
- A relational database is one that organises data into multiple tables
- It uses keys to connect related data which reduces data redundancy, makes efficient use of storage and is easier to maintain
-
A relational database solves the issues in a flat file database:
- A new table could be created to store the tutor information and the tutor information in the student table could be moved to the new table. Then a foreign key in the student table (TutorID) could link a student to their tutor
- Now the name of each tutor and their form room is stored only once
- This means if they change only one piece of data, the data is updated in the entire database and Inconsistency is avoided