Download presentation
Presentation is loading. Please wait.
Published byMarvin Cooper Modified over 8 years ago
1
28 Database Theory 28
2
Database Theory We have looked at the basics of how databases work: Database Tables A A Relational Databases C C Types of Data B B
3
28 Database Theory Database Tables A A Relational Databases C C Types of Data B B Now we’re going to look at a practical example of a relational database:
4
28 Database Theory Simple databases with just one data table are called flat file databases. But using only one table creates BIG problems for larger systems because lots of data can be duplicated and the database becomes very inefficient. So advanced databases use multiple tables They are called relational databases Relational Databases C C
5
28 Database Theory Typical exam question: Explain the relationships between the Hire table and the other two tables. [2] Explain one advantage to the car hire company of using a relational database rather than a single table. [2]
6
28 Database Theory Adding new records in Flat Files & Relational Databases
7
28 Database Theory Start by looking at the data in a flat file What does this mean?
8
28 Database Theory FIESTA KA MONDEO GOLF Mr SmithMr BakerMiss Green Mrs Brown 15 Fri May 14 Thu Jul 14 Thu Jul 16 Sat May 15 Fri Jul 17 Sun May 16 Sat May 15 Fri Jul Is hired for two days… …by Mr Smith Is hired for one day… …by Miss Green Is hired for two days… …by Mrs Brown Is hired for three days… …by Mr Baker
9
28 Database Theory We’re about to add some new hire arrangements. You’ll need to know about how the HireIDs are made… HireID Starts with an H First letter of car model Day and month of hire HG147 H for HireG for Golf147 for 14 th July
10
28 Database Theory Add the new arrangements to the table AB10 WXYFordFiesta£12kManualHF22722/7/152 daysGRE81Miss Green7 Long Row, NewtonLA2 8KE015395 12356
11
28 Database Theory GOLF Mr SmithMiss Green 17 Thu May 16 Wed May 19 Tue Jul Mr Baker MONDEO Miss Green FIESTA MONDEO 15 Sat May 22 Fri Jul 18 Mon Jul 16 Mon May 17 Sun Jul Is hired for two days… …by Miss Green Is hired for one day… …by Mr Baker Is hired for three days… …by Miss Green Is hired for two days… …by Mr Smith
12
28 Database Theory Mrs Brown MONDEO KA Mr Smith FIESTA KA Mrs Brown Miss Green 16 Thu May 27 Wed Jul 25 Mon Jul 26 Tue Jul 16 Wed May 16 Tue May 25 Mon Jul Is hired for one day… …by Mrs Brown Is hired for one day… …by Mr Smith Is hired for two days… …by Miss Green Is hired for three days… …by Mrs Brown
13
28 Database Theory You end up with…
14
28 Database Theory Look at the same data in a relational database For now, we’re just looking at the tables on the bottom of the sheet…
15
28 Database Theory Add the new arrangements… AB10 WXY HF22722/7/15 2 days GRE81
16
28 Database Theory GOLF Mr SmithMiss Green 17 Thu May 16 Wed May 19 Tue Jul Mr Baker MONDEO Miss Green FIESTA MONDEO 15 Sat May 22 Fri Jul 18 Mon Jul 16 Mon May 17 Sun Jul Is hired for two days… …by Miss Green Is hired for one day… …by Mr Baker Is hired for three days… …by Miss Green Is hired for two days… …by Mr Smith
17
28 Database Theory Mrs Brown MONDEO KA Mr Smith FIESTA KA Mrs Brown Miss Green 16 Thu May 27 Wed Jul 25 Mon Jul 26 Tue Jul 16 Wed May 16 Tue May 25 Mon Jul Is hired for one day… …by Mrs Brown Is hired for one day… …by Mr Smith Is hired for two days… …by Miss Green Is hired for three days… …by Mrs Brown
18
28 Database Theory All the new arrangements… If we’d had any new customers, we’d add them in this table If we’d had any new cars, we’d add them in this table …are in the Hire table
19
28 Database Theory Making changes in Flat Files & Relational Databases
20
28 Database Theory Start with the Flat File
21
28 Database Theory Miss Green has just phoned… …she is getting married so please update her name to Mrs Gage Mr Smith is moving house… …please change his details to 8 Low Road, Kirkby, LA6 2RP, 015242 789321
22
28 Database Theory Changes in a Flat File Miss GreenMr Smith
23
28 Database Theory Now look at the same changes here:
24
28 Database Theory Miss Green has just phoned… …she is getting married so please update her name to Mrs Gage Mr Smith is moving house… …please change his details to 8 Low Road, Kirkby, LA6 2RP, 015242 789321
25
28 Database Theory Changes in a Relational Database Miss GreenMr Smith
26
28 Database Theory Advantages of Relational Databases Less duplication (redundancy) Fewer errors (inconsistencies) Easier to make changes More efficient
27
28 Database Theory Talking about relationships in Relational Databases
28
28 Database Theory This is a ?? This is a ?? Recordl Field All this data is stored in a ?? Table This is a ?? This is a ?? Field name This is the ?? Primary Key Re-cap…
29
28 Database Theory DocID Foreign Key PatientID Primary Key DocID Primary Key Relational Databases C C
30
28 Database Theory Identify the primary and foreign keys: Primary key Foreign key A table that links other tables, is called a Link table. Link Table
31
28 Database Theory Describing the relationships: One customer can arrange many hires One car can be hired many times A one-to-many relationship One customer can arrange many hires One car can be hired many times
32
28 Database Theory Patients Patient ID Forename Surname DocID Doctors DocID Surname Department Mobile We’ve seen this before… It’s a ‘One To Many’ relationship One doctor can treat many patients
33
28 Database Theory Let’s go back to the question…
34
28 Database Theory Can we answer these now? Explain the relationships between the Hire table and the other two tables. [2] Explain one advantage to the car hire company of using a relational database rather than a single table. [2]
35
28 Database Theory
36
28 Database Theory
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.