Introduction to databases

Download Report

Transcript Introduction to databases

Databases
What is a database?

A database is a collection of data



Maybe computerised
Will be organised so as to make the retrieval and
maintenance of data as easy as possible
A computerised database:


Offers the great advantage of speed
More sophisticated databases will use database
management software

MS Access is an RDBMS – Relational Database Management
System
Flat files



A flat file is a database held in a single file
The data stored in one file cannot easily be linked to
data stored in another file.
These so-called ‘flat files’ are useful for:




a list of contact names and addresses
a list of student grades
details of a video collection.
A spreadsheet can be used as a flat file database,
with a column representing a field and a row
representing a record.
Flat file problems

Redundant data – repetition of the same data




Errors arising from typing the same data many
times in different records



makes the file larger than necessary
wastes space on disk
makes it slow to retrieve information
Typographical errors occur
Loss of data consistency
Difficulties in updating and modifying data

All occurrences would have to be located and changed
Solving the flat file problems

Study this flat file data for a moment


Identify some of the problems that have occurred
Consider how multiple tables would improve the
database for this orders flat file
Multiple tables




Each entity should have its own table
Each record must have a unique ID.
This is the principle behind relational databases.
The following tables would be created from the previous flat file
Multiple tables

This would then mean that the orders table would look like:
 In reality, the supplier data in the Products table would be
regarded as a separate entity and have its own table
 Why is price retained as a field in the orders table?
Database system .v. flat file

data independence


quality of management information


information more useful as it is based on a single, comprehensive set of data
control over redundancy


structure of the database does not affect the programs which access the
database
data is not stored several times in separate files
consistency of data

because data is only stored once, no possibility of holding different data on
different files (e.g. different addresses for the same employee)
Database system .v. flat file (cont.)

more information available to users


greater security of data


because the data is held in a single, company-wide database, all
users have access to it
users can only view or update the parts they are authorised to
access or change
less time spent inputting data

because it is held only once, there is no duplication of effort
inputting the same data into different files.