1 / 22

ER Modelling III Example

ER Modelling III Example. Digital Voice Systems Data Modelling Deriving Tables Types Mapping to SQL DDL. Introduction. This lecture introduces the Digital Voice Systems Scenario The lecture uses a brief version of the scenario to introduce you to the model.

aderes
Download Presentation

ER Modelling III Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ER Modelling III Example • Digital Voice Systems • Data Modelling • Deriving Tables Types • Mapping to SQL DDL

  2. Introduction • This lecture introduces the Digital Voice Systems Scenario • The lecture uses a brief version of the scenario to introduce you to the model. • The full scenario and solution is in your module pack - you need to attempt the full scenario yourself.

  3. Brief Digital Voice Systems Scenario Modern private digital voice systems exchanges are basically complex computer systems. Private digital telephone networks are often used by organisations with a number of multi-building sites. These sites would be distributed around the country, each site would have one or more digital exchanges. At each site there would be a number of employees directly involved in the running of the voice systems. In particular a system would have to keep track of a telephone exchange manager for each site as well as the telephone operators. These digital exchanges are capable of providing a continual log of their activity. Every call is logged providing information as below: Outgoing calls: source extension, destination number, charge band. Incoming calls: destination extension, duration of call, number of rings before answered etc. Clearly details of many employees would need to be recorded together with the details of their associated telephone extensions. In practice employees might have more than one extension. Some employees also might share extensions and the system would have to be capable of coping with this. Organisations would divide their employees into departments. Calls would be charged against these departments. It will be necessary that each extension would be associated with a single department for call charging.

  4. Building In > 1 m m 1 In > 1 Room Site On v Exchange m Modern private digital voice systems exchanges are basically complex computer systems. Private digital telephone networks are often used by organisations with a number of multi-building sites. These sites would be distributed around the country, each site would have one or more digital exchanges. • What entities can you see - a little imagination is required. • What about the relationships? Try to draw those in. • Site - Building - Room; a simple hierarchy. • You could also have a Floor entity - rooms are often named by building, floor, room number.

  5. Building m In > 1 1 m m 1 In > m 1 Room Site < Manages (voice) On v Employee Exchange 1 m m 1 < Operates Table needed At each site there would be a number of employees directly involved in the running of the voice systems. In particular a system would have to keep track of a telephone exchange manager for each site as well as the telephone operators. • Just use an Employee entity and model this with relationships. • Note: you may have considered a subtype hierarchy – employee to manager and operator

  6. 1 m < from Outgoing Call 1 ^ to m Extension Incoming Call These digital exchanges are capable of providing a continual log of their activity. Every call is logged providing information As below: Outgoing calls: source extension, destination number, charge band. Incoming calls: destination extension, duration of call, number of rings before answered etc. • How do we model this bit? • You will need the Extension entity. (Telephone extension) • Try to add appropriate relationships.

  7. Building Building m In > 1 1 1 m m m 1 In > < from Outgoing Call m 1 1 Room Site Site < Manages (voice) On v ^ to Employee Exchange 1 1 m m Extension m < Plugged into m 1 < Operates Incoming Call Table needed Reviewing what we have so far ... • Try to link these sections. • What is an extension connected to?.

  8. For > m m m Now decompose it. 1 1 m m Extension Extension Employee Employee ?? Now we need a name for the new entity, attributes and a primary key. Trying asymmetric viewing: For a particular extension - what is it a list of ? All the employees with that extension number. For an individual employee - what is this a list of? The employee’s extension number (or numbers) Clearly details of many employees would need to be recorded together with the details of their associated telephone extensions. In practice employees might have more than one extension. Some employees also might share extensions and the system would have to be capable of coping with this. • Starting from the Extension entity, how would you model this?

  9. For > In > 1 1 m m Extension Employee Naming the complex entity Directory Entry • Any ideas for a name for this entity? • How about Directory-Entry • Quite difficult to name…. • We need an attribute for Directory-Entry. • The primary key could be [extn#, emp#] • The entity records an employee being associated with an extension. Any ideas for attributes? • Would a date be appropriate? (always a useful guess) • The date the employee was given the extension number

  10. Testing the primary key • The primary key could be [extn#, emp#] so we do the usual test. • Make up a few rows: • Now try to break the chosen primary key’ • Adding a row with the same primary key value as another row. • If we assume we only hold the latest date on which an extension is allocated to an employee - then the primary key seems to be appropriate.

  11. < Charged To 1 m < From Outgoing Call 1 1 1 ^ In ^ To 1 m m m m Department Extension Employee Incoming Call Organisations would divide their employees into departments. Calls would be charged against these departments. It will be necessary that each extension would be associated with a single department for call charging. • Try to model this ….

  12. 1 m 1 m < In < In Room Building Site m 1 < Manages ^ on 1 m 1 m < Operates m Employee Exchange In > 1 1 1 ^ For m Directory Entry Department Charged > <Plugged m 1 ^ In to into 1 m < From Outgoing Extension m Call 1 m 1 ^ To m Incoming Call The diagram so far .. • The full scenario is in the module pack. Try to re-model the scenario using the full scenario. This diagram is missing another relationship.

  13. 1 m 1 m < In < In Room Building Site m 1 < Manages ^ on 1 m 1 m < Operates m Employee Exchange In > 1 1 1 ^ For m Directory Entry Department Charged > <Plugged m 1 ^ In to into 1 m < From Outgoing Extension m Call 1 m 1 ^ To m Incoming Call Deriving tables from the diagram • 1. How many tables? • How many entity tables? • Where are the relationship tables?

  14. 1 m 1 m < In < In Room Building Site m 1 < Manages ^ on 1 m 1 m < Operates m Employee Exchange In > 1 1 1 ^ For m <<Table>> Directory Entry Department Charged > <Plugged m 1 ^ In to into 1 m < From Outgoing Extension m Call 1 m 1 ^ To m Incoming Call 2. Showing all the postings • Are these correct? • How many postings do we have?

  15. 3. Which tables? • Now we simply lay out the tables as below : • Simple Entities: Site ( Building ( Room ( Extension ( Outgoing_Call ( Incoming_Call ( Department ( Employee ( Exchange ( • Complex Entities: Directory_Entry ( • Relationships: Operates (

  16. 4. Identifiers site#, building#, room#, building#, extn#, extn#, date, time, extn#, date, time, dept#, emp#, exch#, emp#, extn#, - we did this earlier exch#, emp#, - taken from the entities • Simple Entities: Site ( Building ( Room ( Extension ( Outgoing_Call ( Incoming_Call ( Department ( Employee ( Exchange ( • Complex Entities: Directory_Entry ( • Relationships: Operates ( • What is the primary key for the relationship table? • You need the ERD and mapping to tables rule.

  17. m 1 m 1 < In < In Room Building Site m 1 < Manages ^ on 1 m 1 m < Operates m Employee Exchange In > 1 1 1 ^ For m <<Table>> Directory Entry Department Charged > <Plugged m 1 ^ In to into 1 m < From Outgoing Extension m Call m 1 1 ^ To m Incoming Call • Anything to post into Site? • Yes, emp#. • Anything to post into Building? • Yes, what? • Anything to post into Room? • Yes, but pre-posted. • Anything to post into Extension? • Yes, what? • Anything to post into Outgoing_Call? • Yes, but pre-posted. • Anything to post into Incoming_Call? • Yes, but pre-posted. • Anything to post into Department? • No. • Anything to post into Employee? • Yes, what? • Anything to post into Exchange? • Yes, what? 5. Postings Have we done all the postings? - Count them ... • Anything to post into Directory Entry? • Yes but we already did that when we created the complex entity. • Directory_Entry(emp#, extn#, ….

  18. 5. Completed Postings emp#, site#, dept#, exch#, dept#, site#, • Simple Entities: Site (site#, Building (building#, Room (room#, building#, Extension (extn#, Outgoing_Call (extn#, date, time, Incoming_Call (extn#, date, time, Department (dept#, Employee (emp#, Exchange (exch#, • Complex Entities: Directory_Entry (emp#, extn#, • Relationships: Operates (emp#, exch#, • How many foreign keys? • Have we posted all of them?

  19. 6. Assigning further attributes These digital exchanges are capable of providing a continual log of their activity. Every call is logged providing information as below: Outgoing calls: source extension, destination number, charge band. Incoming calls: destination extension, duration of call, number of rings before answered etc. • Where would you assign these attributes? • Where would you record the date of employment of a telephone operator? • The full scenario is in the module pack. Try to assign all the other attributes found there.

  20. Mapping to SQL Data Definition Language CREATE TABLE EXTENSION ( EXTN_NO NUMBER(6) NOT NULL , DEPT_NO CHAR(6) , EXCH_NO NUMBER(4) , CONSTRAINT dept_foreign_key FOREIGN KEY (DEPT_NO) REFERENCES DEPARTMENT (DEPT_NO), CONSTRAINT exch_foreign_key FOREIGN KEY (EXCH_NO) REFERENCES EXCHANGE (EXCH_NO), CONSTRAINT extn_primary_key PRIMARY KEY (EXTN_NO) ) ; Extension (extn#, dept#, exch#)

  21. Creating the SQL script DROP TABLE EXTENSION; DROP TABLE DEPARTMENT; CREATE TABLE DEPARTMENT ( DEPT_NO CHAR(6) NOT NULL, DEPT_NAME CHAR(20), CONSTRAINT dept_primary_key PRIMARY KEY (DEPT_NO)); INSERT INTO DEPARTMENT VALUES (‘D00012’,’Marketing’); ... CREATE TABLE EXTENSION ( EXTN_NO NUMBER(6) NOT NULL , DEPT_NO CHAR(6) , EXCH_NO NUMBER(4) , CONSTRAINT dept_foreign_key FOREIGN KEY (DEPT_NO) REFERENCES DEPARTMENT (DEPT_NO), CONSTRAINT exch_foreign_key FOREIGN KEY (EXCH_NO) REFERENCES EXCHANGE (EXCH_NO), CONSTRAINT extn_primary_key PRIMARY KEY (EXTN_NO) ) ; INSERT INTO EXTENSION VALUES (550551,‘D00012’,8080); ...

  22. Manipulating the Database • Finding the telephone operators on exchange 8080. Operates (emp_no, exch_no) Employee (emp_no, name, dept_no) SELECT E.emp_no, name FROM Employee E, Operates O WHERE E.emp_no = O.emp_no AND exch_no = 8080;

More Related