Christoph F. Eick: Designing E/R Diagrams 1 Designing E/R Diagrams Updated: January 25. 2005.

Slides:



Advertisements
Similar presentations
Database Design The process of finding user requirement
Advertisements

the Entity-Relationship (ER) Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Data Modeling (CB 12) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
The Entity-Relationship Model
Entity-Relationship Models
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
The Entity-Relationship (ER) Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Relational Algebra, R. Ramakrishnan and J. Gehrke Ungraded Homework P1 Reminder : Reserves(sid,bid,day) a. Create a table Together(sid1,sid2,day)
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.) –What are the entities.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.
Lecture 2: Entity/Relationship modelling
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The (min,max) notation (1,1) (0,1) (1,N) (1,1). SUMMARY OF ER-DIAGRAM NOTATION FOR ER SCHEMAS Meaning ENTITY TYPE WEAK ENTITY TYPE RELATIONSHIP TYPE IDENTIFYING.
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
CS 405G Introduction to Database Systems
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Data Modeling Using the Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
NFL E/R Design Problem Design an Entity-Relationship Diagram that models the following objects and relationships in the world of football (NFL): teams,
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Entities and Attributes
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 2: Representing Information with Data Models The lecture notes.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
CMPT 258 Database Systems The Entity-Relationship Model Part II (Chapter 2)
ER Data Models Ctd. CSET 3300.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
09/03/2009Lipyeow Lim -- University of Hawaii at Manoa 1 ICS 321 Fall 2009 Introduction to Database Design Asst. Prof. Lipyeow Lim Information & Computer.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Weak Entity Sets A weak entity is an entity that cannot exist in a database unless another type of entity also exists in that database. Weak entity meets.
Entity-Relationship Model Chapter 3 II COSC 457 Sungchul Hong.
Mapping E/R Diagrams to Relational Database Schemas
advanced data modeling
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
Data Modeling Using the Entity-Relationship (ER) Data Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
ER & Relational: Digging Deeper R &G - Chapters 2 & 3.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
Dr. Eick’s: Homework Solutions COSC Ungraded Homework P1 Reminder : Reserves(sid,bid,day) a. Create a table Together(sid1,sid2,day) that contains.
A short review on entity- relationship modelling.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
COP Introduction to Database Structures
Contents Design Process Modeling Constraints E-R Diagram Design Issues
Comp 1100 Entity-Relationship (ER) Model
Entity- Relationship (ER) Model
بسم الله الرحمن الرحيم.
Instructor: Elke Rundensteiner
Solution Problem1 Exam0 ssn Sal empl. name name Person Team city contr
Entity Relationship Diagrams
Data Modeling with Entity Relationship Diagrams (Cont.)
The Entity-Relationship Model
Question Which of the following plays an important role in representing information about the real world in a database? Explain briefly 1)DDL.
Entity Relation Model Tingting Zhang.
Presentation transcript:

Christoph F. Eick: Designing E/R Diagrams 1 Designing E/R Diagrams Updated: January

Christoph F. Eick: Designing E/R Diagrams 2 Conceptual Data Models  Conceptual data models provide languages to describe conceptual schemas.  Conceptual schemas are used to describe the classes of objects that occur in an application area, their properties, their relationships, and the constraints that hold with respect to those classes of objects.  Center on “ what kind of objects a database contains” and not on “ how these objects are stored” (  Internal Schema) and not on “ how these objects are represented / displayed to a person that accesses the database” (  External Schema).

Christoph F. Eick: Designing E/R Diagrams 3 Conceptual Data Models --- What are they good for?  As a database design tool formalizing the information requirements of the end users  As a documentation tool for databases (to help programmers, especially those that have to update the database)  As a data model of a database management system (only very few experimental systems exist)  As a tool to describe domain ontologies (terminology and concepts in a UoD)  As a tool of system analysis

X X Person name ssn Wedding E/R Model Symbols for COSC 3480 occurred to Is-insured T1 amount (n,m) phone# from Entity Type Attribute Relationship Type Weak Entity Type Identifying Relationship Key Attribute Partial Key Optional Attribute R Entities of type X participate at least n, at most m times in relationship R; * indicates . Y  Entity type X is a subtype of type Y T2 Type T1 and T2 are overlapping; an entity can belong to both T1 and T2; default is disjoint Multi-valued Attribute Derived Attribute T2 T3 T1  T3=T2  T1  

Course Student Department name ssn grade took semesterid title salary (0,30) (0,*) (1,1) University Problem Final’03 COSC 3480 employs Cou# Semester took-not-a-set: -2.5 Other Errors: -1.5 (or  3-4 if major) Grad UGrad  gre (0,*)   mentor name (0,25) (0,2) home (0,*) (1,1))

Christoph F. Eick: Designing E/R Diagrams 6 Exam1 Fall 2005 Problem  Design a “good” entity-relationship diagram that describes the following objects in a university application: students, departments, sections taught in the present and future, and courses. Departments have a name that uniquely identifies the department. Students are identified by a unique social security number, zero, one or multiple addresses, and an optional gpa (new students do not have a gpa yet). Courses have a unique course number and a course title. Courses are offered in one or more sections at a particular time. Sections are identified by the time they are offered (e.g. 10:30-noon TUTH) and by the course they are associated with. Additionally sections are characterized by the class room the section is taught in. Only information concerning sections that are taught in the present or in the future is stored in the database. Students take a course in a particular semester and receive a grade for their performance. Sometimes students take the same course again in a different semester. There are no limits on how many courses a student can complete, and on how many students completed a particular course. Each student is associated with a least one department. Some students are graduate students that are additionally characterized by their most recent GRE-score. Some graduate students work for a department and receive a salary for their services. Each department employs at most 75 graduate students; graduate students are not allowed to work for multiple departments.

Course Student Department name ssn grade took semesterid title salary (0,75) (0,*) (0.*) University Problem Exam1’05 employs Cou# Semester took-not-a-set: -1.5 Section not weak: -2 Other Errors: if minor -2—3 if major Grad  (0,*) assoc name (0,1) (0,*) (1,1) gpa (1,*) gre Section offered Time-offered classroom

Christoph F. Eick: Designing E/R Diagrams 8 Team contr name city Player name ssn birthd played-in. Date pos score HomeVisit Sal (1,1) (25,*) (18,*) (0,*) Solution Problem6 Exam0 Spring 2003 (0,*) play Game# Game Contract set viol –3, Other: -2 pos Month from to (0,*) name

Christoph F. Eick: Designing E/R Diagrams 9 Team empl. contr name city Manager Player Person name ssn weightpos birthd height Game play played-in. Date min score HomeVisit Sal (1,3) (0,4) (1,1) (24,99) (0,1) (22,*) (0,*) NFL E/R Problem (0,*) Scoring: 1.Play relationship a Set: 3 2.Person/Player/Manager: 3 3.Weak Game Entity: 3 4.Played-in: 2 5.Can Only Play once on a day: 1 6.Contract: 3 7.Salary, score, min attribute: 3  

Christoph F. Eick: Designing E/R Diagrams 10 Identifying Keys and Relationships for Entity Types Each entity type that is not subtype of another entity type needs:  Case1: Normal Entity Type (single rectangle) 1.A single attribute (straight line) or 2.A set of attributes or  Case2: Weak Entity Type (double rectangle) 1.A set of relationships (double diamond) or 2.A set of relationships or a single attribute (dotted line) or 3.A set of relationships and a set of attributes (dotted line) that uniquely identifies the instances of the entity type Remark: min-max cardinalities for weak entity types for their participation in identifying relationships have to be (1,1)!!

Male Female Person name ssn Wedding (0,*) E/R Diagram for Multi-Weddings   occurred (0,*) fromto (1,1) Is-insured Company name amount (0,*) location  husband wife

Christoph F. Eick: Designing E/R Diagrams 12 Valid E/R Diagrams An E/R diagram is valid if and only if:  It is syntactically correct (e.g. specifies all key constraints,…)  It specifies the entity types, relationship types, attribute types, and subtype relationships necessary to satisfy all information requirements.  It does not specify any invalid constraints.

Christoph F. Eick: Designing E/R Diagrams 13 Priorities when Choosing Between Valid E/R Diagrams 1.Express all constraints (you can express!) 2.Use and do not change terminology and class structure of the application domain 3.Keep it simple (avoid defining entity types that do not serve any purpose) 4.Avoid redundancy (but derived attributes are okay)!

Christoph F. Eick: Designing E/R Diagrams 14 A Quite Bad E/R Diagrams Company ssn gender works- for department gpa (0,*) Name Person salary (0,*) is-married- to husband wife (0,*) takes Section  (0,*)  Course (0,*) C# S# time

Christoph F. Eick: Designing E/R Diagrams 15 Example: Too many Entity Types / Don’t use Foreign Keys Company ssn name is- insured Name Person (0,*) Example: Persons as well as animals can be insured Animal P# (0,*) A# Boss-ssn Bad E/R Diagram!

Christoph F. Eick: Designing E/R Diagrams 16 E/R Diagram Design – Typical Errors 1.Missing Constraints 2.Unexpressed Constraints due to bad design 3.Every entity type needs a key 4.Attribute associated with the wrong entity type (relationship type) 5.Relationships are sets! 6.No partial participation in relationships! 7.Missing existence dependencies (use subclasses) 8.Invalid constraints 9.Using Subtypes for n:1 relationships; using relationships when subtypes should be used. 10.When defining relationships: Too general entity types for participating entities 11.Too many entity types 12.Using foreign keys instead of relationships

Christoph F. Eick: Designing E/R Diagrams 17 Other Issues in E/R Design 1.No relationships of relationships --- solution: create an entity type that represent instances of the relationship (or use aggregation as discussed in the textbook) 2.value or entity type --- solution: choose entity type if it helps expressing constraints; otherwise, use value-type.

Christoph F. Eick: Designing E/R Diagrams 18 University E/R Design Problem Design a “good” entity-relationship diagram that describes the following objects in an university application: students, instructors, professors, and courses. Students are subdivided into graduate and undergraduate students. Students take a course in a particular semester and receive a grade for their performance. Sometimes students take the same course again in a different semester. There are no limits on how many courses a student can take, and on how many students completed a particular course. Each graduate student has exactly one advisor, who must be a professor, whereas each professor is allowed to be the advisor of at most 20 students. Courses have a unique course number and a course title. Students and professors have a name and a unique ssn; students additionally have a gpa; moreover, graduate students have a GRE-score, and undergraduate students have a single or multiple majors. Professors can be students and take courses, but graduate students cannot be undergraduate students. Indicate the cardinalities for each relationship type; assign roles (role names) to each relationship if there are ambiguities! Use sub-types, if helpful to express constraints!

Course Student Professor Person name ssn grade gpa took semesterid title gre (0,1) (0,*) (0,20) University Problem (slightly different from Exam0’03)  advises Cou# Semester Enrolls-not-a-set: -4 Student must be ugrad or grad: -1 Other Errors: -2 (or –3 if quite major) Ugrad Grad  major (0,*)   

Hotel Gold_Cl. Client addr ssn discount G# room-type address number (0,*) A:=guaranteed; B:=has_transaction; C:=for_hotel; D:=consists_of; E:=for_category; F=avail-rooms; G=total-rooms; modified on Feb. 3, 2004  Ho# Transaction Category Cred-Card (0,*) (0,1) Reservation company C E D (1,1) B (1,50) (1,1) (0,300) (1,1) F #avail fromrateto day_ made Res# (1,1) tr# (0,*) (1,*) phone# A Problem 1 Exam1 Fall’03 Grading: Minor Error: -1 Medium Error: -2 Major Error: -3 or –4 0-4 points if too many errors day Date #totalG (0,*) (1,*)

Christoph F. Eick: Designing E/R Diagrams 21 Aggregation  Used when we have to model a relationship involving (entity sets and) a relationship set.  Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. * Aggregation vs. ternary relationship :  Monitors is a distinct relationship, with a descriptive attribute.  Also, can say that each sponsorship is monitored by at most one employee. budget did pid started_on pbudget dname until Departments Projects Sponsors Employees Monitors lot name ssn since

Christoph F. Eick: Designing E/R Diagrams 22 NFL E/R Design --- Ungraded Homework --- due: Th., Jan. 27,2005 Design an Entity-Relationship Diagram that models the following objects and relationships in the world of football (NFL): teams, players, games, managers and contracts. Each (NFL-) team has a unique team name, and a city it plays in. Each person being part of the NFL-world has a unique ssn and a name. Additionally, for players their weight, height, position and birth dates are of importance. Players have a contract with at most one team and receive a salary for their services, and teams have at least 24 and at most 99 players under contract. Each team has one to three managers; managers can work for at most 4 teams and receive a salary for each of their employments. Players cannot be managers. A game involves a home-team and visiting- team; additionally, the day of the game, and the score of the game are of importance; teams play each other several times in a season (not on the same day!). Moreover, for each game played we like to know which players participated in the game and how many minutes they played. Indicate the cardinalities for each relationship type; assign roles (role names) to each relationship if there are ambiguities! Use sub-types, if helpful to express constraints!