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

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

Entity Relationship Diagrams
Logical Database Design Reading: C&B, Chap 17. Dept. of Computer Science, University of Aberdeen2 In this lecture you will learn What is logical database.
Exercise 1 Consider the ER diagram below. Assume that an employee may work in up to two departments or may not be assigned to any department. Assume that.
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Relationships Relational Database. Identifying Entities… In the previous tutorial you learnt about identifying entities in a flat file database. Also.
Section 09 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 09 (a) ER Modelling In Practice DIGITAL VOICE SYSTEM.
Section 09ER Decomposition Of Many To Many1 HSQ - DATABASES & SQL And Franchise Colleges 09 ER Decomposition of Many-to-Many.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
Database Management System Module 3:. Complex Constraints In this we specify complex integrity constraints included in SQL. It relates to integrity constraints.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
ENTITY RELATIONSHIP MODELLING
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 2 Relational Theory DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH.
1 Class Agenda – 09/20/2011  Answer questions about exam  Evaluate database design homework  Review database design homework for syntax and logic 
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Agenda for Week 1/31 & 2/2 Learn about database design
Database Design Concepts Info1408
Lecture 10 Conversion to tables Database Design Concepts INFO1408.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
M1G Introduction to Database Development 1. Databases and Database Design.
Prevalent Database Models (Advantages of a database over flat files)
Entity/Relationship Modelling
WJEC Applied ICT Databases – Attributes & Entities Entities A database contains one or more related tables. Each table holds all of the information.
Database Systems Lecture 5 Natasha Alechina
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
Entity Relationship Model Chapter 6. Basic Elements of E-R Model Entity Object of the real world that stores data. Eg. Customer, State, Project, Supplier,
CS2008/CS5035 Exam Preparation. Dept. of Computing Science, University of Aberdeen2 Organization of Lecture Notes Group 1 - SQL –L1 – Introduction –L2.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
Project Implementation for COSC 5050 Distributed Database Applications Lab2.
Limitations of the relational model. Just as the relational model supplanted the network and hierarchical model so too will the object – orientated model.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
Introduction to Accounting Information Systems
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
RDBMSSection Relational DBMS DATABASE DEVELOPMENT And Franchise Colleges By MANSHA NAWAZ.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
M1G Introduction to Database Development 2. Creating a Database.
CS370 Spring 2007 CS 370 Database Systems Lecture 4 Introduction to Database Design.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
IS 475/675 - Introduction to Database Design
COMU114: Introduction to Database Development 1. Databases and Database Design.
Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Section 11ER Tables1 HSQ - DATABASES & SQL And Franchise Colleges 11 ER Tables By MANSHA NAWAZ.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Week 2 Introduction to Data Modelling
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Sample Table Standard Notation Entity name in uppercase
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Chapter 27 Network Management Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fundamentals of DBMS Notes-1.
Let try to identify the conectivity of these entity relationship
Logical Database Design and the Rational Model
Generalization.
The Relational Model Textbook /7/2018.
Mapping an ERD to a Relational Database
Database Management system
Database Management system
eSeries Entities By Julie Ladner
Presentation transcript:

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. The full scenario and solution is in your module pack - you need to attempt the full scenario yourself.

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.

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. Building Exchange SiteRoom 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. m 1 In > 1 m 1 m On v

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 Site Building Exchange Room Employee 1 m Table needed < Operates 1 m < Manages (voice) 1 m 1 m In > m 1 1 m On v

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. Extension 1 m Incoming Call 1 m Outgoing Call < from ^ to

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

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? Extension Employee 1 m ?? 1 m 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) Employee m Now decompose it. Extension m m For >

Naming the complex entity Any ideas for a name for this entity? How about Directory-Entry –Quite difficult to name…. Extension Employee 1 m 1 m For > In > 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 Directory Entry

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.

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 …. Extension 1 m Incoming Call Outgoing Call Employee Department 1 m 1 m ^ In < Charged To < From 1 m 1 m ^ To

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. 1 < Operates Call into ^ For 1m ^ on Site Building Employee < In Exchange Room < In < Manages 1m Extension Outgoing Call Incoming < From ^ To <Plugged Directory Entry ^ In m 1 m 1 Department In > Charged > to 1m m m m m m m m

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

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

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 (

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

5. Postings 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? Anything to post into Directory Entry? –Yes but we already did that when we created the complex entity. –Directory_Entry(emp#, extn#, …. Have we done all the postings? - Count them... 1 < Operates Call into ^ For 1m ^ on Site Building Employee < In Exchange Room < In < Manages 1m Extension Outgoing Call Incoming < From ^ To <Plugge d Directory Entry ^In^In m 1 m 1 Department In > Charged > to 1 m m m m m m m m >

5. Completed Postings 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#, emp#, site#, dept#, exch#, dept#, site#, How many foreign keys? Have we posted all of them?

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.

Mapping to SQL Data Definition Language CREATE TABLE EXTENSION ( EXTN_NONUMBER(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#)

CREATE TABLE DEPARTMENT ( DEPT_NO CHAR(6) NOT NULL, DEPT_NAME CHAR(20), CONSTRAINT dept_primary_key PRIMARY KEY (DEPT_NO)); Creating the SQL script CREATE TABLE EXTENSION ( EXTN_NONUMBER(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 DEPARTMENT VALUES (‘D00012’,’Marketing’);... DROP TABLE EXTENSION; DROP TABLE DEPARTMENT; INSERT INTO EXTENSION VALUES (550551,‘D00012’,8080);...

Manipulating the Database Finding the telephone operators on exchange 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;