Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company.

Similar presentations


Presentation on theme: "Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company."— Presentation transcript:

1 Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company

2 Section 08 (a)ER Modelling In Practice2 Case Study : QUICKHIRE Car Company A nationwide car hire company with depots and hirepoints in all major towns. The depots, where cars are held, are distinct from the hirepoints where the customer hires their car. One hirepoint has access to several depots and each depot may supply cars to many hirepoints. A unique employee number, name, address and telephone number. If the employee works at hirepoints a list of those hirepoints at which the employee may work should be available. Employees work either at hirepoints or at depots. Depot employees do not usually move but hirepoint employees frequently move from one hirepoint to another due to the seasonal nature of the trade. In addition, each hirepoint employee has a known set of hirepoints where they may be used (within travelling distance). Depot number, location, number of employees, a list of employees at the depot and a detailed list of cars currently held at each depot. The cars are identified by a unique number and should also have details of registration number, car type, colour, year of manufacture, number of miles travelled, date of last service, miles at last service. Hirepoints need a unique hirepoint number, name and location, a list of employees currently working at the hirepoints and a list of the depots a hirepoint may use. Each hiring is assigned a unique number and requires details of customer name, customer address and car numbers. A note is kept of the employee who did the hiring, date hired, and return date. Since a customer may be a company rather than an individual, provision is made for the possibility of more than one car being hired in an individual hiring. Each customer is assigned a unique number and many customers may have more than one hiring outstanding at the same time.

3 Section 08 (a)ER Modelling In Practice3 Where to start? The basic (simple entities) –Car –Hirepoint –Depot –Employee –Customer –Hiring Identifiers? Attributes? Definitions –Try to do these yourself.. reg#, car type, colour, year, miles_travelled, date _last_service, miles_last_service ….. (A physical car not Car_Type) hp#, address, name … A place where hirings are arranged. depot#, address … A place where cars are stored / serviced emp#, name, DOB, ….. (Works at Hirepoint or Depot..) cust#, address … A person or company who may hire a car hiring#, date, ….. A contract to hire a car or cars Note: Why not put hp#, cust#, car#, emp# in Hiring (yet)?

4 Section 08 (a)ER Modelling In Practice4 Where to start? Cont. Where is the money? –Which entity is a transaction of some kind - central to the business? Hiring ! Hiring Hirepoint at m 1 What can we link this to easily? A Hiring is at exactly 1 Hirepoint A Hirepoint may arrange 0,1,m Hirings How about Employee, and Customer - try to extend the ERD to include these. How about Hirepoint? –You try it.

5 Section 08 (a)ER Modelling In Practice5 Adding Employee and Customer From the scenario: Each hiring is assigned a unique number and requires details of customer name, customer address and car numbers. A note is kept of the employee who did the hiring, date hired, and return date. Hiring Hirepoint at m 1 to m 1 Customer by m 1 Employee What about cars? –Try to add this bit.

6 Section 08 (a)ER Modelling In Practice6 Cars... Each hiring is assigned a unique number and requires details of customer name, customer address and car numbers. A note is kept of the employee who did the hiring, date hired, and return date. Since a customer may be a company rather than an individual, provision is made for the possibility of more than one car being hired in an individual hiring. Hiring Car of m m How can you have a Hiring with no Cars? Would you allocate Cars immediately to a Hiring booked 3 weeks in advance? Could you have cancelled Hirings? Regular Hirings?

7 Section 08 (a)ER Modelling In Practice7 Decomposing the m:m Decompose this yourself …. Hiring Car of m m ?? ? m 1 Hiring ? m 1 Car What is the new entity?? Try Asymmetric Viewing. From left to right: –For a Hiring the new entity gives a list of all the Cars in that Hiring. From right to left: –For a Car the new entity give a list of all past Hirings it has been in (or any it has been assigned to in the future).

8 Section 08 (a)ER Modelling In Practice8 Attributes for the new entity. Try to think of some attributes for the new entity (A particular car in a particular hiring). –What would Quickhire need to record about the car before it is driven away? Miles_out, miles_in, condition_out, condition_in, fuel_out, fuel_in You may have others too. If you were sitting in one of the ‘things’ recorded by the new entity by the side of the road, what would you call it? A Hired Car ! ?? ? m 1 Hiring ? m 1 Car in m 1 Hiring is m 1 Car Hired Car

9 Section 08 (a)ER Modelling In Practice9 A Primary Key for Hired Car A reasonable guess for a Primary Key would be [ hiring#, reg# ] We need to test this out as in the lecture on complex entities. We will use the table type: hired_car(hiring#, reg#, miles_out, …...) Draw a table occurrence with three sensible rows yourself. in m 1 Hiring is m 1 Car Hired Car

10 Section 08 (a)ER Modelling In Practice10 Testing the hiring#, reg# Primary Key Now try to enter the first value of the Primary Key [H4, T125TGY] in a new row …. Use whatever you have in your example. –See if it makes sense to have a different mileage. Does this make any sense? –Can a car go out on the same hiring with two different mileages?? It looks like the Primary Key is probably valid.

11 Section 08 (a)ER Modelling In Practice11 The ERD so far... Notice we don’t have Depots yet. As we already have Employe we will continue with this aspect. in m 1 Hiring Hired Car to m 1 Customer by m 1 Employee is m 1 Car Hirepoint at 1 m

12 Section 08 (a)ER Modelling In Practice12 Employees A unique employee number, name, address and telephone number. If the employee works at hirepoints a list of those hirepoints at which the employee may work should be available. Employees work either at hirepoints or at depots. Depot employees do not usually move but hirepoint employees frequently move from one hirepoint to another due to the seasonal nature of the trade. In addition, each hirepoint employee has a known set of hirepoints where they may be used (within travelling distance). Try to fill in the degree of association an membership class for the diagram below. Employee Currently works at 1 m DepotHirepoint Works at 1 m Later we will find that both of these new relationships will require at table. Employee Currently works at DepotHirepoint Works at

13 Section 08 (a)ER Modelling In Practice13 Hirepoint Employees …. hirepoint employees frequently move from one hirepoint to another due to the seasonal nature of the trade. In addition, each hirepoint employee has a known set of hirepoints where they may be used (within travelling distance). Try to model this aspect... Employee Currently works at 1 m Hirepoint Employee Currently works at 1 m Hirepoint may work at m m Another m:m to decompose - an attribute of the new entity will be distance_from_home. Try to decompose this m:m relationship after the lecture and examine its primary key as before.

14 Section 08 (a)ER Modelling In Practice14 An almost complete ERD - for you to finish

15 Section 08 (a)ER Modelling In Practice15 Finishing off After the lecture you need to : –Determine the Primary key for the decomposition entity Employee_available_for_HP –Look at the decomposition entity HP_Depot_Access: Read about the original M:M relationship in the scenario. Find an attribute for the entity (something similar to the Employee_available_for_HP would do). Determine an appropriate primary key. –Find another relationship between Depot and Hired_Car. –Work out how the relationship between Car and Depot relates to the scenario. –In another session, try to draw the whole ERD just from the scenario & memory. Don’t forget the primary keys of m:m relationships. You may find you need to sneak a look at a slide sometimes.

16 Section 08 (a)ER Modelling In Practice16 End of Lecture


Download ppt "Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company."

Similar presentations


Ads by Google