DATABASE DESIGN I - 1DL300

Similar documents
DATABASE DESIGN I - 1DL300

DATABASDESIGN FÖR INGENJÖRER F

DATABASTEKNIK - 1DL116

DATABASE TECHNOLOGY. Spring An introduction to database systems

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

DATABASE DESIGN I - 1DL300

1/24/2012. Chapter 7 Outline. Chapter 7 Outline (cont d.) CS 440: Database Management Systems

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Entity Relationship Data Model. Slides by: Shree Jaswal

DATABASE TECHNOLOGY - 1DL124

ER-to-Relational Mapping

COIS Databases

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Chapter 8: Enhanced ER Model

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Enhanced Entity-Relationship (EER) Modeling

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

Enhanced Entity- Relationship Models (EER)

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

LELCTURE 4: ENHANCED ENTITY-RELATIONSHIP MODELING (EER)

Outline. Note 1. CSIE30600 Database Systems ER/EER to Relational Mapping 2

A l Ain University Of Science and Technology

Advance Database Management System

Chapter 4. Enhanced Entity- Relationship Modeling. Enhanced-ER (EER) Model Concepts. Subclasses and Superclasses (1)

Data Modeling Using the Entity-Relationship (ER) Model

CS 405G: Introduction to Database Systems

Chapter 2: Entity-Relationship Model

ER to Relational Mapping

A l Ain University Of Science and Technology

Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping

Database Management

Conceptual Data Models for Database Design

Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

LECTURE 3: ENTITY-RELATIONSHIP MODELING

THE ENHANCED ER (EER) MODEL CHAPTER 8 (6/E) CHAPTER 4 (5/E)

Intro to DB CHAPTER 6

Data Modeling Using the Entity- Relationship Model Design & Analysis of Database Systems

Topic 5: Mapping of EER Diagrams to Relations

Overview of Database Design Process. Data Modeling Using the Entity- Relationship (ER) Model. Two main activities:

EECS 647: Introduction to Database Systems

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

Database Design Process

Chapter 6: Entity-Relationship Model

Database Systems ER Model. A.R. Hurson 323 CS Building

Data Modeling Using the Entity-Relationship Model

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Chapter Outline. Note 1. Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

CS3200 Database Design Spring 2018 Derbinsky. Entity-Relationship (ER) Diagrams. Lecture 7

DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL. 1 Powered by POeT Solvers Limited

Conceptual Database Design

Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model

Chapter 6: Entity-Relationship Model. E-R Diagrams

CS 338 The Enhanced Entity-Relationship (EER) Model

Chapter 6: Entity-Relationship Model

Translation ER/EER to relational

Chapter 7: Entity-Relationship Model


Chapter 7: Entity-Relationship Model

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4-1

High Level Database Models

Chapter 6: Entity-Relationship Model

CSE 530A. ER Model. Washington University Fall 2013

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Definition. 02. Data Modeling. Example ABC Company Database. Data Modeling Importance

Chapter 7: Entity-Relationship Model

Chapter 9 Outline. Relational Database Design by ER and EERto-Relational. Mapping Fundamentals of Database Systems

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

CMP-3440 Database Systems

Lecture3: Data Modeling Using the Entity-Relationship Model.

Translating an ER Diagram to a Relational Schema

DATABASE DESIGN PROCESS

Lecture 10. Spring 2018 Borough of Manhattan Community College

4. Entity Relationship Model

Lecture 10 - Chapter 7 Entity Relationship Model

Database Design Process. Requirements Collection & Analysis

Database Technology. Topic 4: Enhanced Entity- Relationship (EER) Modeling

Chapter 7: Entity-Relationship Model

Entity-Relationship Model. Dr. Samaresh Mishra, School of Computer Engineering, KIIT University, Bhubaneswar

Represent entities and relations with diagrams

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

Database Management System (15ECSC208) UNIT I: Chapter 1: Introduction to DBMS and ER-Model

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Relational Database Systems Part 01. Karine Reis Ferreira

Overview of db design Requirement analysis Data to be stored Applications to be built Operations (most frequent) subject to performance requirement

Chapter 2 ENTITY RELATIONSHIP MODEL

2. DatabaseDesign. Master I Software Engineering. Dr. Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras

High-Level Database Models (ii)

Entity-Relationship Model

Chapter 2: Entity-Relationship Model. Entity Sets. Entity Sets customer and loan. Attributes. Relationship Sets. A database can be modeled as:

COMP102: Introduction to Databases, 13

COSC 304 Introduction to Database Systems Enhanced Entity-Relationship (EER) Modeling

The En'ty Rela'onship Model

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

Transcription:

DATABASE DESIGN I - 1DL300 Fall 2010 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/ht10/ Manivasakan Sabesan Uppsala Database Laboratory Department of Information Technology, Uppsala University, Uppsala, Sweden 2010-11-03 1

Introduction to Database Design Using Entity-Relationship Modeling Elmasri/Navathe ch 7,9 Padron-McCarthy/Risch ch 2-3 Manivasakan Sabesan Department of Information Technology Uppsala University, Uppsala, Sweden 2010-11-03 2

ER-modeling Aims at defining a high-level specification of the information content in the database. History Chen, P. P. S., The entity-relationship model: towards a unified view of data, ACM TODS, 1, 1 1976, p. 9-36. Why ER-models? High-level description - easier to understand for non-technicians More formal than natural language - avoid misconceptions and multiple interpretations Implementation independent (of DBMS) - less technical details Documentation Model transformation to an implementation data model 2010-11-03 3

Entity type and entity An entity type represents a physical or abstract concept with some sort of identity. The individual instances of the concept are members of a set of entities that have the same set of attributes. Entity types express the intention, i.e. the meaning of the concept whereas the set of entities represents the extension of that type. Names of entity types are given in singular form. The description of an entity type is called its schema. PERSON name, ssn, address, phoneno Each attribute in an entity type is associated with a domain that indicates the allowed values of that attribute. 2010-11-03 4

Attribute An attribute is a characteristic or aspect that describe an entity (and is defined on entity types). Every attribute has a domain (or value set). A domain specifies the set of allowed values each individual attribute can be assigned. There is (at least) six different types of values for attributes: simple/ sex: M or F composite name: (Ior, Karlsson) single-valued/ name: Ior Karlsson multivalued friends: {Nasse, Puh,...} stored/ birthdate: 980917 derived age : 0 null Note! ER-diagram Simple Composite Multi valued Deri ved 2010-11-03 5

Attribute cont... Key: an attribute that has unique values for every instance of an entity type is called a key attribute. Sometimes several attributes are used together to get a unique key. An entity type can have more than one key. key hello 2010-11-03 6

Relationship type and relationship A relationship type represents a relationship (or relation/connection), between a number of entity types. A relationship type R is a set of relationships (i.e. relational instances) or tuples. A relationship type, R, can mathematically be defined as: R E 1 E 2 E n where each Ej is a entity type. A tuple (or an instance) t R is written as (e 1, e 2,..., e n ) or <e 1, e 2,..., e n > where e j E j. 2010-11-03 7

Structural constraints for relationship types Cardinality ratio constraint specifies the number of relational instances that an entity can take part in. For binary relationship types: one-to-one (1:1) one-to-many (1:N) 1 1 many-to-many (M:N) 1 N M N 2010-11-03 8

Structural constraints cont.... Participation constraint Partial Total specifies whether the entity existence is dependent of another entity via a relationship type. E.g. can an employee exist without working for a department? Partial participation: the entity can exist without this relationship Total participation: the entity requires this relationship in order to exist. emplo yee works_f or depar tment manages 2010-11-03 9

Roles of relationship types A role name specifies what role an entity type plays in a specific relationship Role names are sometimes used in ER-diagrams to clarify the roles of the participating entity types. Employee manager 1 N worker Supervision 2010-11-03 10

Attributes for relationship types Also a relationship type can have attributes. E.g. in the case where the weekly number of hours an employee works on a project should be kept, that can be represented for each instance of the relation works- on. If the relation is a 1:1 or 1:N relation, the attribute can be stored at one of the participating entities. When the relation is of the type M:N one must store the attributes with the instance of the relation. 2010-11-03 11

Weak entity types Weak entity types are those that are meaningless without an owner entity type. Weak entities are uniquely identified in the extension with their owner s key attributes together with its own (broken) underlined attribute. The relationship to the owner is called the identifying relationship. 2010-11-03 12

ER-notation (Elmasri/Navathe Figure 7.14) 2010-11-03 13

Example ER-modeling An enterprise consists of a number of departments. Each department has a name, a number, a manager, and a number of employees. The starting date for every department manager should also be registered. A department can have several office rooms. Every department finances a number of projects. Each project has a name, a number and an office room. For each employee, the following information is kept: name, social security number, address, salary and sex. An employee works for only one department but can work with several projects that can be related to different departments. Information about the number of hours (per week) that an employee work with a project should be stored. Information about the employees manager should also be stored. 2010-11-03 14

Entity and relationship types in the example (see figures 3.8-3.13 in Elmasri/Navathe) Entity types: EMPLOYEE(name(fstname,famname), ssn, address, sex, salary) DEPARTMENT( name, number, {room}) PROJECT( name, number, room, department) Relationship types: An employee MANAGES a department 1:1 Every department FINANCES at least one project 1:N Every employee WORKS-FOR a department N:1 Every employee WORKS -WITH one (or several) project(s) M:N An employee IS-MANAGER over several employees 1:N 2010-11-03 15

ER-diagram for the example fstname name sex salary ssn EMPLOYEE 1 N WORKS-FOR MANAGES 1 1 name number DEPARTMENT 1 FINANCES room famname 1 N M startdate N address IS-MANAGER WORKS-WITH N PROJECT name number room hours 2010-11-03 16

ER model transformations Replacing multi-valued attributes by an entity type Dept id Name Location DEPARTMENT Dept id Name Location 1 N DEPARTMENT located at LOCATION 2010-11-03 17

ER model transf. cont.... Replacing M-N relationships with an entity type and binary relationships. TEACHER TEACHER 1 lectures N N lectures booked for N N LECTURES Time ROOM N Time 1 ROOM N consists of COURSE 1 COURSE 2010-11-03 18

Product-detail relationship (one-to-many) PRODUCT part_of DETAIL p 1 p 2 p 3 p 4... r 1 r 2 r 3 r 4 r 5 r 6 r 7... d 1 d 2 d 3 d 4 d 5 d 6 d 7... 2010-11-03 19

cardinality/participation vs. min-max PRODUCT 1 N part_of DETAIL PRODUCT (0,N) (1,1) part_of DETAIL 2010-11-03 20

Extended Entity-Relationship (EER) modeling The intention of using an E-R diagram is to use it as a basis for user communication or for getting to a good design specification. i.e. try to make it simple and avoid to much complexity. EER (extended or enhanced ER) introduces several notational extensions to deal concepts such as: Superclass /subclass (supertype/subtype, is-a relationship) specialization/generalization constraints Aggregation (whole/part or part-of relationship) Union types (category) 2010-11-03 21

EER diagram notation for specialization and subclass (Elmasri/Navathe Figure 7.19) 2010-11-03 22

Subclasses, superclasses & inheritance Two generic ideas for creating superclass/subclass relationships Specialization of superclass into subclasses Generalization of subclasses into a superclass Constraints and characteristics of spec. & gen. Constraints Predicate-defined (condition-defined) sub-classes Attribute-defined User-defined Disjointness Disjoint Overlapping Completeness Total Partial 2010-11-03 23

Generalization of subclasses (Elmasri/Navathe Figure 7.21) 2010-11-03 24

Overlapping (nondisjoint) subclasses (Elmasri/Navathe Figure 7.23) 2010-11-03 25

Representation of aggregation in ER notation There is no explicit representation of aggregation in ER notation implicitly a relationship type can represent an aggregation relationship e.g. a relationship type that details are part of a product. PRODUCT 1 N part_of DETAIL objectifying the relationship type makes it explicit and referable. 1 N 1 1 PRODUCT consist ASSEMBLY part_in DETAIL 2010-11-03 26

Representation of aggregation in ER notation (Elmasri/Navathe Figure 7.28) 2010-11-03 27

Union of two entity types(elmasri/navathe Figure 7.21) 2010-11-03 28

A UML conceptual schema (Elmasri/Navathe Figure. 9.1) 2010-11-03 29

Specialization/generalization in UML (Elmasri/Navathe Figure 9.2) 2010-11-03 30

Alternative diagrammatic notation for ER/EER (Elmasri/Navathe Figure A.1) 2010-11-03 31