Database Systems Unit 7. Logical Modeling. DB / PRM1 / db07_logicalmodelling.ppt / Version Learning Goals

Ähnliche Dokumente
Conceptual Data Modeling "Enhanced Entity-Relationship"

Unit 1. Motivation and Basics of Classical Logic. Fuzzy Logic I 6

A Classification of Partial Boolean Clones

Harry gefangen in der Zeit Begleitmaterialien

Level 2 German, 2015

Exercise (Part I) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

Exercise (Part II) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

VGM. VGM information. HAMBURG SÜD VGM WEB PORTAL - USER GUIDE June 2016

Introduction FEM, 1D-Example

NEWSLETTER. FileDirector Version 2.5 Novelties. Filing system designer. Filing system in WinClient

VGM. VGM information. HAMBURG SÜD VGM WEB PORTAL USER GUIDE June 2016

FEM Isoparametric Concept

Tube Analyzer LogViewer 2.3

p^db=`oj===pìééçêíáåñçêã~íáçå=

Dynamic Hybrid Simulation

prorm Budget Planning promx GmbH Nordring Nuremberg

Titelmasterformat Object Generator durch Klicken bearbeiten

Martin Luther. Click here if your download doesn"t start automatically

FEM Isoparametric Concept

Brandbook. How to use our logo, our icon and the QR-Codes Wie verwendet Sie unser Logo, Icon und die QR-Codes. Version 1.0.1

General info on using shopping carts with Ogone

Lehrstuhl für Allgemeine BWL Strategisches und Internationales Management Prof. Dr. Mike Geppert Carl-Zeiß-Str Jena

LiLi. physik multimedial. Links to e-learning content for physics, a database of distributed sources

Zu + Infinitiv Constructions

Exercise (Part XI) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

!! Um!in!ADITION!ein!HTML51Werbemittel!anzulegen,!erstellen!Sie!zunächst!ein!neues! Werbemittel!des!Typs!RichMedia.!!!!!!

ISO Reference Model

Word-CRM-Upload-Button. User manual

Kursbuch Naturheilverfahren: Curriculum der Weiterbildung zur Erlangung der Zusatzbezeichnung Naturheilverfahren (German Edition)

Level 2 German, 2013

Die einfachste Diät der Welt: Das Plus-Minus- Prinzip (GU Reihe Einzeltitel)

German translation: technology

Unit 4. The Extension Principle. Fuzzy Logic I 123

Ein Stern in dunkler Nacht Die schoensten Weihnachtsgeschichten. Click here if your download doesn"t start automatically

Geometrie und Bedeutung: Kap 5

Introduction FEM, 1D-Example

Ewald s Sphere/Problem 3.7

Ingenics Project Portal

Can I use an older device with a new GSD file? It is always the best to use the latest GSD file since this is downward compatible to older versions.

Die Bedeutung neurowissenschaftlicher Erkenntnisse für die Werbung (German Edition)

Prof. S. Krauter Kombinatorik. WS Blatt03.doc

Max und Moritz: Eine Bubengeschichte in Sieben Streichen (German Edition)

Data Structures and Algorithm Design

HIR Method & Tools for Fit Gap analysis

Mitglied der Leibniz-Gemeinschaft

auf differentiellen Leitungen

DYNAMISCHE GEOMETRIE

eurex rundschreiben 094/10

Handbuch der therapeutischen Seelsorge: Die Seelsorge-Praxis / Gesprächsführung in der Seelsorge (German Edition)

Flow - der Weg zum Glück: Der Entdecker des Flow-Prinzips erklärt seine Lebensphilosophie (HERDER spektrum) (German Edition)

Was heißt Denken?: Vorlesung Wintersemester 1951/52. [Was bedeutet das alles?] (Reclams Universal-Bibliothek) (German Edition)

ISO Reference Model

Preisliste für The Unscrambler X

"What's in the news? - or: why Angela Merkel is not significant

NVR Mobile Viewer for iphone/ipad/ipod Touch

Grade 12: Qualifikationsphase. My Abitur

Automatentheorie und formale Sprachen reguläre Ausdrücke

Die Datenmanipulationssprache SQL

Abschnitt 1. BPM als Lingua franca. Management, Fachbereiche und IT Ist BPM ein Weg zur (Auf-)Lösung der Sprachbarriere?

Teil 2.2: Lernen formaler Sprachen: Hypothesenräume

Hardwarekonfiguration an einer Siemens S7-300er Steuerung vornehmen (Unterweisung Elektriker / - in) (German Edition)

Instruktionen Mozilla Thunderbird Seite 1

J RG IMMENDORFF STANDORT F R KRITIK MALEREI UND INSPIRATION ERSCHEINT ZUR AUSSTELLUNG IM MUSEUM LU

STRATEGISCHES BETEILIGUNGSCONTROLLING BEI KOMMUNALEN UNTERNEHMEN DER FFENTLICHE ZWECK ALS RICHTSCHNUR FR EIN ZIELGERICHTETE

Mit Legacy-Systemen in die Zukunft. adviion. in die Zukunft. Dr. Roland Schätzle

Interpolation Functions for the Finite Elements

Level 1 German, 2016

Mock Exam Behavioral Finance

To conjugate in the present tense: take the regular verb infinitive kaufen remove the -en ending add the following endings. er, sie, es t sie,sie en

Level 1 German, 2014

Challenges for the future between extern and intern evaluation

Big Data Analytics. Fifth Munich Data Protection Day, March 23, Dr. Stefan Krätschmer, Data Privacy Officer, Europe, IBM

Jägersprache, Wildkunde und Begriffe aus der Jagd: Schwerpunkt Jägerprüfung Rotwild, Rehwild, Gamswild, Steinwild, Muffelwild (German Edition)

Diabetes zu heilen natürlich: German Edition( Best Seller)

Unterspezifikation in der Semantik Hole Semantics

Web-Apps mit jquery Mobile: Mobile Multiplattform-Entwicklung mit HTML5 und JavaScript (German Edition)

Prediction Market, 28th July 2012 Information and Instructions. Prognosemärkte Lehrstuhl für Betriebswirtschaftslehre insbes.

Übung 2: Wie oft musst du das machen? Oft (often), manchmal (sometimes) oder nie (never)? Name: das Auto waschen

Bosch Rexroth - The Drive & Control Company

Where are we now? The administration building M 3. Voransicht

Materialien zu unseren Lehrwerken

Wer bin ich - und wenn ja wie viele?: Eine philosophische Reise. Click here if your download doesn"t start automatically

Funktion der Mindestreserve im Bezug auf die Schlüsselzinssätze der EZB (German Edition)

Einsatz einer Dokumentenverwaltungslösung zur Optimierung der unternehmensübergreifenden Kommunikation

p^db=`oj===pìééçêíáåñçêã~íáçå=

Hausaufgabe 1-4. Name: If homework late, explanation: Last class homework is being accepted: If correction late, explanation: Student Self-Grading

Rätsel 1: Buchstabensalat klassisch, 5 5, A C (10 Punkte) Puzzle 1: Standard As Easy As, 5 5, A C (10 points)

Der Topos Mütterlichkeit am Beispiel Bertolt Brechts "Der kaukasische Kreidekreis" und "Mutter Courage und ihre Kinder" (German Edition)

Fachbereich 5 Wirtschaftswissenschaften Univ.-Prof. Dr. Jan Franke-Viebach

Einkommensaufbau mit FFI:

Labour law and Consumer protection principles usage in non-state pension system

Franke & Bornberg award AachenMünchener private annuity insurance schemes top grades

1. Fundamentals of Processes: Core Processes [ID: ] 2. Fundamentals of Processes: Core Processes [ID: ]

1. Fundamentals of Processes: Core Processes [ID: ] 2. Fundamentals of Processes: Core Processes [ID: ]

ReadMe zur Installation der BRICKware for Windows, Version ReadMe on Installing BRICKware for Windows, Version 6.1.2

Duell auf offener Straße: Wenn sich Hunde an der Leine aggressiv verhalten (Cadmos Hundebuch) (German Edition)

Transkript:

Database Systems Unit 7 Logical Modeling DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-1 Learning Goals In this unit you will learn how to translate an ERD into a relational DB how to represent relationship types with different cardinalities using the foreign key concept different techniques to represent generalizations / specializations in a relational database DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-2 1

Example: ERD of Company DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-3 Example Company: Database Schema Diagram DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-4 2

Mapping Relationship Types The only construct for representing relationships in a relational database is a foreign key A foreign key represents per default a one-to-many relationship Any other cardinality may be represented using multiple foreign keys, additional relations, and/or additional constraints DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-5 Composite Attributes The relational database model does usually not support structured attributes. Therefore, composite attributes from the conceptual model have to be mapped. For mapping, we may choose out of three possibilities: Each component of the composite attribute becomes a separate attribute in the relation (make sure that togetherness is still visible in attribute names). The composite attribute becomes one single (big) attribute in the relation. Use a separate relation with the same structure as the composite attribute. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-6 3

Step1: Translating Regular Entity Types Every regular entity type in the ERD becomes a relation in the relational schema. Every attribute of the entity type becomes an attribute of the relation. Include only the simple component attributes of a composite attribute. One of the identifiers/keys is chosen to be the primary key of the relation; the other identifiers become keys and may be implemented in most DBMS using unique constraints DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-7 Step2: Mapping of Weak Entity Types For each weak entity type W in the ER schema with the owner entity type E, create a relation R. Include all simple attributes (or simple components of composite attributes) of W as attributes of R. In addition, include as foreign key attributes of R the primary attributes of the relation that correspond to the owner entity type. The primary key of R is the combination of the primary key(s) of the owner(s) and the partial key of the weak entity type W, if any. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-8 4

Example Employee (1,1) Dependent_of (0,N) Dependent SSN Name Name Employee(SSN, Name, PK(SSN)) Dependent(EmployeeSSN, Name, PK(EmployeeSSN, Name), FK(EmployeeSSN) -> Employee) DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-9 Step 3: Mapping of Binary 1:1 Relationship Types For each binary 1:1 relationsship type R in the ER schema identify the relations S and T that correspond to the entity types participating in R. There are three possible approaches: Foreign key approach: Choose one of the relations S, say and include as a foreign key in S the primary key of T. (Choose an entity type with total participation for S.) Merged relation option: Merge the two entity types and the relationship into a single relation (appropriate when both participations are total). Cross-reference or relationship relation option: Later. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-10 5

Example: 1:1-Relationship Type with mandatory Participation for both Entity Types Customer (1,1) has (1,1) Shipping Info Customer# Name ShipInfo# Ship-Address Customer (Customer#, Name, PK(Customer#)) Shipping_Info (ShipInfo#, Ship-Address, Customer# UNIQUE PK(ShipInfo#), FK(Customer#->Customer)) DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-11 Example: 1:1-Relationship Type with optional Participation DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-12 6

Example: 1:1-Relationship Typemwith optional Participation for both Entity Types Male (0,1) married (0,1) Female SSN Name Date SSN Name Male(SSN, Name, FemaleSSN nv Unique, Date, PK(SSN), FK(FemaleSSN) -> Female)) Female (SSN, Name, PK(SSN)) Alternatively: Male(SSN, Name, PK(SSN)) Female(SSN, Name, MaleSSN nv Unique, Date, PK(SSN), FK(MaleSSN) -> Male)) DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-13 Step 4: Mapping of Binary 1:N Relationship Types For each regular binary 1:N relationship type R, identify the relation S that represents the participating entity type at the N-side of R. Include as foreign key in S the primary key of the relation T the 1-side. (This can be done since each entity S is related to at most one entity instance T.) Include any attributes of the 1:N relationship type as attributes of S. We may not ensure that every primary key value occurs at least once as a foreign key value. As a result, foreign key values may be null. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-14 7

Example: 1:N-Relationship Type with mandatory Participation DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-15 Step 5: Mapping of Binary M:N Relationship Types For each binary M:N relationship type R, create a new relation S to represent R. Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types; their combination will form the primary key of S. Include also any attributes of the M:N relationship type as attributes of S. Notice that we can always map 1:1 or 1:N relationships in a manner similar to M:N relationships by cross-reference (relationship relation) approach. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-16 8

Example: Binary M:N Relationship Type DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-17 Example (cont.) DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-18 9

Mapping Recursive Relationship Types The same rules as for binary relationships must also be applied here: For one-to-many and one-to-one cardinalities, only one foreign key is needed and may be combined with further constraints For many-to-many cardinalities, an additional relationship table is also needed here The same methods as discussed before for binary relationship types can be used with recursive ones. The only exception is that all foreign keys reference one and the same relationship DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-19 Example SSN Name is subordinate of Employee (0,1) (0,N) is manager of Employee (SSN, Name, Mngr_SSN nv, PK(SSN), FK(Mngr_SSN) -> Employee) manages DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-20 10

Step 6: Mapping of Multivalued Attributes For each multivalued attribute A, create a new relation R. This relation R will include an attribute corresponding to A, plus the primary key attribute K as a foreign key in R of the relation that represents the entity type or relationship type that has A as an attribute. The primary key of R is the combination of A and K. If the multivalued attribute is composite, we include its simple components. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-21 Example DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-22 11

Step 7: Mapping of N-ary Relationship Types For each n-ary relationship type R, where n > 2, create a new relation S to represent R. Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types. Also include any attributes of the n-ary relationship type as attributes of S. The primary key of S is usually a combination of all the foreign keys that reference the relations representing the participating entity types. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-23 Example: Ternary Relationship Type DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-24 12

Mapping of Specialization or Generalization There are several options for mapping a number of subclasses that together form a specialization (or alternatively, that are generalized into a superclass). Multiple relations Superclass and subclasses Multiple relations Subclass relations only. Single relation with one type attribute. Single relation with multiple type attributes. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-25 Modeling Superclass/Subclasses by Multiple Relations Subclass relations only. Objective: Represent only the subclasses as relations in the database. The superclass will implicitly be represented by the union of all the relations representing subclasses Mapping: Each subclass type inherits explicitly all the attributes from the superclass. Each subclass inherits explicitly all the relationship types from the superclass. Mandatory relationships (1, x) become optional (0, x). DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-26 13

Modeling Superclass/Subclasses by a Single Relation Objective: Represent the superclass and all of the subclasses in only one relation in the database Mapping: Attributes of the subclasses become optional attributes of the superclass. Relationship types of the subclass types become relationship types of the superclass. Mandatory relationship types (1, x) become optional (0, x). Make sure that attribute values allow to decide whether an entity instance belongs to a given subclass type or not. If necessary, add a discriminating attribute. DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-27 EER Representation of a Super-/Sub-Entity Hierarchy DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-28 14

Examples: Mapping of Superclass-Subclasses DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-29 Mapping Process: Overview Analyze redundancies in the ERD Remove generalization hierarchies Map regular entity types, attributes, and keys Map relationship types and attributes Map weak entity types and its relationship to the parent entity type Optimize the relational schema using relation merging and/or splitting DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-30 15

Entity Merging For performance or complexity reasons it might sometimes be useful to merge two related entity types into one Depending on the cardinalities of the involved relationship type, we always have to keep in mind the secondary effects of this merging Redundancy Anomalies DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-31 Redundancy Analysis Types of redundancies: Attributes that may be derived (calculated) from other attributes Attributes that may be derived from relationships and attributes in other entities (usually aggregated values) Implicit relationship types Two solutions: Do not translate redundant structures into the relational schema Ensure that redundancy is controlled by the DBMS DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-32 16

Correspondence between ER and Relational Models ER Model Relational Model Entity type Entity relation 1:1 or 1:N relationship type Foreign key (or relationship relation) M:N relationship type Relationship relation and two foreign keys n-ary relationship type Relationship relation and n foreign keys Simple attribute Attribute Composite attribute Set of simple component attributes Multivalued attribute Relation and foreign key Value set Domain Key attribute Primary key DB / PRM1 / 24.04.2008 db07_logicalmodelling.ppt / Version 2.0 7-33 17