Upload
preston-park
View
216
Download
0
Embed Size (px)
Citation preview
Database: Relational Vs Flat File
Databases - Structure
• Flat file database, contains only one table• Relational database, contains more than
one table where relationships exist between the data in the table
• A flat file database often suffers from inefficient repetition of data.
• Normalisation is the process of removing this repetition by crafting relationships between tables.
Databases – Flat File Vs Relational Database
Name Department Boss Phone
Smith Sales Britney Lurgi 9123 456
Jones Sales Britney Lurgi 9123 456
Lennon Sales Britney Lurgi 9123 456
Sade Transport Tom Brick 9876 543
Masoch Transport Tom Brick 9876 543
STAFF TABLE
Name Department
Smith Sales
Jones Sales
Lennon Sales
Sade Transport
Masoch Transport
DEPARTMENTS TABLE
Department Boss Phone
Sales Britney Lurgi 9123 456
Transport Tom Brick 9876 543
+ No unnecessary data repetition
+ Department info easily modified in one operation.
4
Types of Relationships, connection between data
• One-to-one relationship:
Eg. Airline’s passenger details:
passengers Seats1
Each passenger has only one seat and each seat can be assigned to only one passenger.
A record in one table is connected to only one record in a second table.
5
Types of Relationships, connection between data
• One-to-many relationship:• Eg. customer details & job quotation:
The one supplier can provide MANY products, but each product comesfrom ONE supplier.Also, eg. several workers share single telephone extensions; each extension record is related to several employee’s records.
6
Types of Relationships, connection between data
• many-to-many relationship:• Eg. Student details and subjects tables:
Each student studies many subjects and each subject has many students
students subjects
Databases – Flat File Vs Relational
• School and Student Details• If data was only in one table, with fields of
surname, fname, school, address, phone no, fax no, etc. What would be the consequence of a school changing its phone number?
• A RDMS with two tables, one with student info and one with school information will avoid this duplication.
Databases – Flat File Vs Relational
• Advantages of a relational database:– reduced data redundancy – unnecessary
duplication of data– improved data integrity or accuracy of data– able to access the data from separate but
related tables or files very quickly and simply– allows easy querying, reporting, etc.