Download presentation
Presentation is loading. Please wait.
Published byLarissa Gellatly Modified over 10 years ago
1
Section 08ERD Modelling1 08 - ERD Modelling HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ
2
Section 08ERD Modelling2 Entity Relationship Modelling Introduction In this lecture we will try out a practical example of Entity-Relationship data modelling. Data Modelling is a very creative process - logic, intuition and imagination are all needed. At various stages you will need to attempt problems yourself so you will need a pen and paper. E-R data modelling is the subject of more than half the examination or ica Modelling from datastore and a case study scenario in this lecture.
3
Section 08ERD Modelling3 ERD Examples Example 1 ERD from DATASTORE PO – PURCHASE ORDERS Example 2 ERD from DATASTORE FLIGHTS Example 3 ERD from a CASE STUDY FILM CLUB
4
Section 08ERD Modelling4 Example 1 ERD from DATASTORE PO – PURCHASE ORDERS
5
Section 08ERD Modelling5 ER MODEL : WORKED EXAMPLE MODELLING FROM DATASTORES ORDERS 1.Identify all entities in the above form. ORDERS SUPPLIERS PARTS PAYMENT-TERMS (PT)* tabular list of payment terms CONTACT* tabular list of contact staff 2.Allocate main attributes identified. ORDERS(po#, odate) SUPPLIERS(s#, sname, saddress, …….) PARTS(p#, pdesc, …..) PT(pt#, ptdesc) CONTACT(c#, cname, cext)
6
Section 08ERD Modelling6 3.Derive Entity Relationships 1 ORDER must have 1 SUPPLIER 1 SUPPLIER may have 0,1,M ORDER 1 ORDER must have 1,M PARTS 1 PART may be on have 0,1,M ORDER 1 ORDER must have 1 PT 1 PT may be on have 0,1,M ORDER 1 ORDER must have 1 CONTACT 1 CONTACT may be on have 0,1,M ORDER 4Diagram (ERD) for the above showing entities of interest with their associated attributes, relationships and dependency.
7
Section 08ERD Modelling7
8
Section 08ERD Modelling8 5.List a set of skeleton tables derived from your model ORDERS(po#, odate) SUPPLIERS(s#, sname, saddress, …….) PARTS(p#, pdesc, …..) PAYMENT-TERMS(pt#, ptdesc) CONTACT(c#, cname, cext) supplies(s#, po#) contains(p#, QTY, po#) terms(po#, pt#) postaff(po#, c#)
9
Section 08ERD Modelling9 6. Populate your skeleton tables using the data provided in the above order form.
10
Section 08ERD Modelling10 The previous data set is only a partial view. Additional orders can be generated and added to the database. The next slide shows how the sample order (figure A-2) affects our database. Note : No REDUNDANT or DUPLICATED data in tables which show strong data INTEGRITY.
11
Section 08ERD Modelling11
12
Section 08ERD Modelling12 terms (po#, pt#) 0025941 0025953 contains (p#, QTY, po#) CPU0122002594 PRI62143002594 MON0231002594 CON0614002594 CPU0151002594 KEY03110002594 CPU0722002594 CPU01210002595 PRI6214 5002595 MON0234002595 CON0624002595 CPU0161002595 CPU0742002595 PAYMENT-TERMS (pt#, ptdesc) 1COD 27 days 330 days 445 days CONTACT (c#, cname, cext) 01BLOGGS FRED 321 02SMITH HARRY 322 supplies (s#, po#) 000001002594 000002002595 postaff (po#, c#) 259401 259500259502
13
Section 08ERD Modelling13 Airlines hold information about flights. Data is held as follows : Flight Aircraft MakeSeatsAirportCityA-timeD-time BA069747 BA402LHRLondon-1300 BA069747 BA402ZRHZurich14301530 BA069747 BA402BAHBahrain23000015 BA069747 BA402SEZSeychelles05450645 BA069747 BA402MRUMauritius0910- SK586DC8 DC123LISLisbon-1500 SK586DC8 DC123ZRHZurich18151855 SK586DC8 DC123CPHCopenhagen21102145 SK586DC8 DC123ARNStockholm2255- SK783DC8 DC123CPHCopenhagen-0940 SK783DC8 DC123ATHAthens14001500 SK783DC8 DC123DAMDamascus1700- SK961DC10 DC230CPHCopenhagen-1810 SK961DC10 DC230ATHAthens20300030 SK961DC10 DC230JNBJohannesburg0935- Example 2 ERD from DATASTORE FLIGHTS
14
Section 08ERD Modelling14 ER MODEL : WORKED EXAMPLE SOLUTION 1 : ERD FROM DATASTORES FLIGHTS
15
Section 08ERD Modelling15 uses carries Aircraft Airport Flight (flight#, arrival_airport, depart_airport, arrival_time, depart_time) Airport (code, city) Aircraft (aircraft, no_of_seats) Identifier of flight seems strange. ‘Flight_no’ alone should identify a flight. SOLUTION 2 : ERD FROM DATASTORES FLIGHTS
16
Section 08ERD Modelling16 carries Stops_at Aircraft Airport Stopover Flight (flight#, arrival_airport, depart_airport, arrival_time, depart_time) Stopover (flight_no, code, arrival_time, depart_time) Airport (code, city) Aircraft (aircraft, no_of_seats) Flight Leaves_from Departs_from Arrives_at SOLUTION 3 : ERD FROM DATASTORES FLIGHTS
17
Section 08ERD Modelling17 Film Club Case Study: Film Club UK is a company that owns or leases a number of small cinemas in the UK. They have commissioned a database designer to design a database solution to enable them to maintain details about their cinemas and the films that they show. Note that it is possible to have two cinemas in the same location with the same name (there used to be two Odeons in Newcastle). It is also possible to have different films with the same title (for example, different versions of a Shakespeare play). Films are scheduled for one or more showings at a cinema within a ‘season’. Season details are to be notified in advance of the dates and times of showings, takings, etc. to be notified later. Any one film may have more than one season at any one cinema (for example, a cinema showing ‘The Snowman’ each Christmas). At present, all cinemas are single-screen. Example 3 ERD from a CASE STUDY
18
Section 08ERD Modelling18 Queries: –Details of number of employees (if any – some cinemas are small and manned by volunteers) at a cinema –Analyse takings and numbers of showings for films with times and dates of showings –List cinemas by seating capacity –List films shown anywhere since a certain date –List and summarise films by classification.
19
Section 08ERD Modelling19 Film Club UK is a company that owns or leases a number of small cinemas in the UK. They have commissioned a database designer to design a database solution to enable them to maintain details about their cinemas and the films that they show. Entities (and initial thoughts on relationships) Cinema Film Shows m m What does this ERD say about Cinemas and Films? –Write down the enterprise rules shown on the diagram (0,1,m etc.) This looks sensible but we need to know more about cinemas and films. Just because it looks good does not mean it is correct. –We have not looked at dealing with m:m relationships yet - very complicated. A good start - but what next? –Find attributes and identifier for these entities.
20
Section 08ERD Modelling20 Note that it is possible to have two cinemas in the same location with the same name (there used to be two Odeons in Leicester Square). It is also possible to have different films with the same title (for example, different versions of a Shakespeare play). Cinema Film Shows m m Cinema:Identifier:Cinema_id Attributes:Cinema_name, location, address, …. Film:Identifier:Film_id Attributes:title, duration, category, …. Do these make good sense? Could we have missed things at this stage? Clearly an iterative process.
21
Section 08ERD Modelling21 Films are scheduled for one or more showings at a cinema within a ‘season’. Season details are to be notified in advance of the dates and times of showings, takings, etc. to be notified later. Cinema Film Shows m m Showing Season More entities... Showing: Attributes: date, time, takings? and Try to redraw the E-R diagram including these 2 entities. A useful trick: Where is the ‘money’? –Working backwards from entities that are key business things (money?) can work well.
22
Section 08ERD Modelling22 Write out the enterprise rules for this version. Notice the direction of the relationship names. –The direction is away from the ‘business entity. –You can get a lot out of ‘Where is the money?’ and ‘Where is the business?’ Cinema Film at 1 m Season of 1 m We can add showing later... A cinema has 0,1,m season(s) A season is at exactly 1 cinema A film is shown in 0,1,m season(s) A season of exactly 1 film So what about the showing entity? Try to add the showing entity to your ERD.
23
Section 08ERD Modelling23 A season involves 0,1,m showing(s) A showing is in exactly 1 season Why not relate showing to film? It is a showing of a film … All the showings in a season are the same film. Could you have a season that does not have any showings? (yet!) Write out the enterprise rules for new relationship. Cinema Film at 1 m Season of 1 m Showing in m 1
24
Section 08ERD Modelling24 Any one film may have more than one season at any one cinema (for example, a cinema showing ‘The Snowman’ each Christmas). At present, all cinemas are single- screen. Cinema Film at 1 m Season of 1 m Showing in m 1 Have we coped with this already? Will the model cope with multi-screen cinemas? We would need a screen entity - try this for yourself later.
25
Section 08ERD Modelling25 Identifiers Showing Season Season: Identifier: season_id or film, cinema, start_date ?? Attributes: start_date, end_date, total_takings Showing: Identifier: season_id, date, time or showing_id Attributes: takings, adult_tickets, child_tickets, concession_tickets, free_passes, …… Is total_takings redundant? This is a derived attribute - explained later. and
26
Section 08ERD Modelling26 ERD SAMPLES Ascent Resources Ascent S/W and ERD Solutions Installing Ascent At Home Using Ascent - ER Modeling Library of Free Data Models
27
Section 08ERD Modelling27 End of Lecture
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.