28 Database Theory 28. Database Theory We have looked at the basics of how databases work: Database Tables A A Relational Databases C C Types of Data.

Slides:



Advertisements
Similar presentations
GCSE Computing#BristolMet Session Objectives# 21 MUST describe methods of validating data as it is input. SHOULD explain the use of key fields to connect.
Advertisements

Access A Relational Database Management System. Prof. Leighton2 Database ► A database is a collection of data that’s related to a particular topic ► A.
Relational Database Need to Knows. What is a database? Data - is just a pile of numbers or stats. A business "organises" the data to be meaningful and.
Database Tables two order-entry scenarios: A customer wants to cancel an order that she's placed. If her address is in a separate table from her.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Databases ©
Database revision.
NORMALIZATION: ‘1NF’ The general rule: ‘’Any field which can have many, must have its own table’’ By Sam Beaumont.
Lesson Objectives By the end of this lesson you will be able to: 1.Assign appropriate primary keys/key fields 2.Identify foreign keys in different tables/files.
N5 Databases Notes Information Systems Design & Development: Structures and links.
Our world depends on databases
5 Day Forecast Mon Tues Wed Thu Fri.
Prepared By: Bobby Wan Microsoft Access Prepared By: Bobby Wan
Databases Key Revision Points.
Database Normalization
Database Concepts Relational Databases Start ….
Database Relationships
Chapter 4 Relational Databases
Databases A brief introduction….
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER


MON TUE WED THU
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
Logo Calendar – January 2012 TO DO LIST 01/04/2012 Example TO DO LIST
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
2017 Jan Sun Mon Tue Wed Thu Fri Sat
Primary Longman Elect 6B Chapter 5 Adverbs.

ANNUAL CALENDAR HOLIDAYS JANUARY FEBRUARY MARCH APRIL MAY JUNE
HOLIDAYS ANNUAL CALENDAR JANUARY FEBRUARY MARCH APRIL MAY JUNE
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Starter You’ve witnessed a crime.
Jan Sun Mon Tue Wed Thu Fri Sat
HOLIDAYS ANNUAL CALENDAR JANUARY FEBRUARY MARCH APRIL MAY JUNE
Database Theory.
Relational Databases Farrokh Alemi, PhD Narrated by Farhat Fazelyar
Assignment Six: Campaign Schedule
2008 Calendar.
Talking about weekly activities
S M T W F S M T W F
January MON TUE WED THU FRI SAT SUN
Sun Mon Tue Wed Thu Fri Sat
1 - January - Sun Mon The Wed Thu Fri Sat
2 0 X X s c h e d u l e 1 MON TUE WED THU JANUARY 20XX FRI SAT SUN MEMO.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Calendar
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Sun Mon Tue Wed Thu Fri Sat

1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
January MON TUE WED THU FRI SAT SUN
S M T W F S M T W F
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Sun Mon Tue Wed Thu Fri Sat
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
WEB PAGES: Tables Welcome Back !.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
1 January MON TUE WED THU FRI SAT SUN MEMO 2 February MON TUE WED THU FRI SAT SUN.
2008 Calendar.
S M T W F S M T W F
S M T W F S M T W F
1 January MON TUE WED THU FRI SAT SUN MEMO 2 February MON TUE WED THU FRI SAT SUN.
Presentation transcript:

28 Database Theory 28

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

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:

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

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]

28 Database Theory Adding new records in Flat Files & Relational Databases

28 Database Theory Start by looking at the data in a flat file What does this mean?

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

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

28 Database Theory Add the new arrangements to the table AB10 WXYFordFiesta£12kManualHF22722/7/152 daysGRE81Miss Green7 Long Row, NewtonLA2 8KE

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

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

28 Database Theory You end up with…

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…

28 Database Theory Add the new arrangements… AB10 WXY HF22722/7/15 2 days GRE81

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

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

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

28 Database Theory Making changes in Flat Files & Relational Databases

28 Database Theory Start with the Flat File

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,

28 Database Theory Changes in a Flat File Miss GreenMr Smith

28 Database Theory Now look at the same changes here:

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,

28 Database Theory Changes in a Relational Database Miss GreenMr Smith

28 Database Theory Advantages of Relational Databases Less duplication (redundancy) Fewer errors (inconsistencies) Easier to make changes More efficient

28 Database Theory Talking about relationships in Relational Databases

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…

28 Database Theory DocID Foreign Key PatientID Primary Key DocID Primary Key Relational Databases C C

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

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

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

28 Database Theory Let’s go back to the question…

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]

28 Database Theory

28 Database Theory