Practical Relevance Examples Class Laboratory

Slides:



Advertisements
Similar presentations
Relational Database Design Via ER Modelling
Advertisements

Prof. Sin-Min Lee Department of Computer Science
Normalisation. Informal guidelines  Semantics of the attributes  easy to explain relation  doesn’t mix concepts  Reducing the redundant values in.
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
1 Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
Entity-Relationship (E-R) Model
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
Enhanced Entity-Relationship Model (EER) 1. Enhanced-ER (EER) Model Concepts Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses,
ER- and EER-to-Relational Mapping
Entities and Attributes
1 More on ER Model Detail Relationships 4. 2 Attributes  Attribute  A property or characteristic of an entity type that is of interest to the organisation.
Introduction to Database Systems Conceptual Modeling
Introduction to Database Systems Mapping ER Models to Relational Schemas Irvanizam Zamanhuri, M.Sc Informatics (Computer Science) Study Program Syiah Kuala.
Database Systems Lecture # 7 8 th Feb, Conceptual and Logical Design Person buys Product name pricenamessn Conceptual Model: Relational Model: (plus.
(Extended) Entity Relationship Modelling and Mappings to the Relational Data Model.
1 CSE 480: Database Systems Lecture 4: Enhanced Entity-Relationship Modeling Reference: Read Chapter 8.1 – 8.5 of the textbook.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set. – (customer-id, account-number)
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
ER/EER to Relational Mapping Chapter 9. STEP 1 ENTITY TYPE E (non weak) -> NEW RELATION T RELATION T: – includes all simple attributes (non composite,
Exam 1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
IS6145 Database Analysis and Design Lecture 5: Enhanced Entity-Relationship (EER) Modeling Rob Gleasure
Exam 1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Enhanced Entity-Relationship and UML Modeling. 2.
Chapter 2: Entity-Relationship Model
Simplified phases of Database Design
Databases (CS507) CHAPTER 7.
IS6125 Database Analysis and Design Lecture 7: Enhanced Entity-Relationship (EER) Modeling Rob Gleasure
Enhanced Entity-Relationship Modeling
Enhanced Entity-Relationship Modeling
Enhanced Entity-Relationship and Object Modeling Objectives
© Shamkant B. Navathe CC.
Methodology Logical Database Design for the Relational Model
Conceptual Design & ERD Modelling
Relational Database Design by ER- and EER-to- Relational Mapping
The Enhanced Entity- Relationship (EER) Model
EER Model – Chapter
Session 2 Welcome: The sixth learning sequence
Enhanced Entity-Relationship (EER) Modeling
IS6145 Database Analysis and Design Lecture 5: Enhanced Entity-Relationship (EER) Modeling Rob Gleasure
Entity-Relationship Model
ER- and EER-to-Relational
Database EER.
9/5/2018.
Lecture3: Data Modeling Using the Entity-Relationship Model.
© Shamkant B. Navathe CC.
IS6145 Database Analysis and Design Lecture 5: Enhanced Entity-Relationship (EER) Modeling Rob Gleasure
Chapter 8: Mapping a Conceptual Design into a Logical Design
Enhanced Entity-Relationship Modeling
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter Entity-Relationship Modeling & Enhanced Entity- Relationship Modeling.
© Shamkant B. Navathe CC.
IS6125 Database Analysis and Design Lecture 7: Enhanced Entity-Relationship (EER) Modeling Rob Gleasure
376a. Database Design Dept. of Computer Science Vassar College
Chapter 6: Entity-Relationship Model
Enhanced Entity-Relationship Modeling
Relational Database Design by ER- and EER-to- Relational Mapping
Sampath Jayarathna Cal Poly Pomona
Relational Database Design by ER- and EERR-to-Relational Mapping
Chapter Entity-Relationship Modeling & Enhanced Entity- Relationship Modeling.
Mapping an ERD to a Relational Database
Database EER.
Sampath Jayarathna Cal Poly Pomona
© Shamkant B. Navathe CC.
Relational Database Design by ER- and EER-to-Relational Mapping
Enhanced Entity-Relationship (EER) Modeling
CS4222 Principles of Database System
Presentation transcript:

05 - (Extended) Entity Relationship Modeling and Mappings to the Relational Data Model

Practical Relevance Examples Class Laboratory Class 1 Understanding ER Diagramming. Laboratory Lab 2 Practical ER Diagramming.

Multi-Valued Attributes Create a relation for each multi-valued attribute { primary_key(Ei) U multi-valued attribute } The primary key is (primary_key(Ei) U multi-valued attribute) dateofbirth name given family STUDENT studno contact

Mapping Roles & Recursive Relationships The function of an entity type in a relationship type STAFF name appraiser appraisee APPRAISAL 1 m roomno STAFF(name, roomno, ??? )

Multiple Roles between Entity Types 1. Treat each relationship type separately 2. Distinct roles are represented by different foreign keys drawing on the same relation given family name name SUPERVISE 1 m roomno STAFF STUDENT 1 m EXAMINER STAFF(name,roomno) STUDENT(studno,given,family, ??? ) EXAMINER( ??? ) SUPERVISOR( ??? ) EXAM-SUPER( ??? ) studno

Non-binary Relationship roomno STAFF STAFF name p given family courseno equip name TUTORS m n COURSE STUDENT slot subject studno COURSE(courseno, subject, equip) STUDENT(studno, givenname, familyname) STAFF(staffname, roomno) TUTORS( ??? )

Comparative Terms

Subclasses and Superclasses Superclasses, Subclasses; Specialisation & Generalisation Relationships Subclasses and Superclasses a subclass entity type is a specialised type of superclass entity type a subclass entity type represents a subset or subgrouping of superclass entity type’s instances e.g. undergraduates and postgraduates are subclasses of student superclass Attribute Inheritance subclasses inherit properties (attributes) of their superclasses

Constraints on Specialisation & Generalisation the process of defining a set of more specialised entity types of an entity type Generalisation the process of defining a generalised entity type from a set of entity types Predicate/Condition defined determine the entities that will become members of each subclass by a condition on an attribute value. All member instances of the subclass must satisfy the predicate e.g. first years and second years are subclasses of undergraduates based on their year attribute. User defined no condition for determining subclass membership

Constraints on Specialisation & Generalisation Disjointness Overlap the same entity instance may be a member of more than one subclass of the specialisation Disjoint the same entity instance may be a member of only one subclass of the specialisation Completeness Total every entity instance in the superclass must be a member of some subclass in the specialisation Partial an entity instance in the superclass need not be a member of any subclass in the specialisation

Specialisation & Generalisation Relationships name given family STUDENT studno d undergraduate postgraduate  thesis title year STAFF tutor 1 m

Superclasses, Subclasses Specialisation & Generalisation Relationships ACADEMIC ADMIN STAFF TECHNICAL payroll no name length of service level grade project  O

Superclasses, Subclasses Specialisation & Generalisation Relationships EMPLOYEE STUDENT PERSON O name salary fee  d RESEARCH TEACHING POST GRAD UNDER thesis LECTURING TUTORS address project FINAL YEAR year = 3 SUPERVISOR 1-2 courseno

Categories and Categorisation a single superclass/subclass relationship with more than one superclass, where the superclasses represent different entity types (sometimes with different keys) PERSON COMPANY U OWNER  personid compid duration of ownership

Specialisation & Generalisation Option A 1. Create a relation for superclass 2. Create a relation for each subclass consisting of: {primary_key of superclass} U {attributes of subclass} key for subclass is (primary_key of superclass) name given family STUDENT studno d undergraduate postgraduate  thesis title year Inclusion dependency: p<key>(superclass)  p<key>(subclass ) Covering dependency: n (number of subclasses)  p<key>(subclass ) = p<key>(superclass) i=1 Disjoint dependency:  p<key>(subclass ) = 

Specialisation & Generalisation Option B 1. Create a relation for each subclass consisting of: {primary_key U {attributes U {attributes of of superclass} of superclass} subclass} key for each relation is (primary_key of superclass) name given family STUDENT studno d undergraduate postgraduate  thesis title year Works for total and disjoint constraints Partial: lose any entity that is not in a subclass Overlapping: redundancy To recover the superclass can do an OUTER UNION on the subclass relations

Specialisation & Generalisation Option C 1. Create one relation consisting of: {primary_key U {attributes U {attributes U {type of superclass} of superclass} of all subclasses} attribute} key for subclass is (primary_key of superclass) name given family STUDENT studno d undergraduate postgraduate  thesis title year Many ‘not-applicable’ nulls Does away with joins Disjoint: one type which indicates which subclass the tuple represents Overlap: set of types = number of subclasses Partial: type is null \ represents superclass

Specialisation & Generalisation Overlapping 1.STAFF(payrollno,name,lengthofservice) ACADEMIC(payrollno,level) TECHNICAL(payrollno,project) ADMIN(payrollno,grade) 2.ACADEMIC(payrollno,name,lengthofservice, level) TECHNICAL(payrollno,name,lengthofservice, project) ADMIN(payrollno,name,lengthofservice,grade) 3.STAFF(payrollno,name,lengthofservice,level, project,grade,type1,type2,type3) STAFF(payrollno,name,lengthofservice,level, project,grade,type) type = powerset of classes ACADEMIC ADMIN STAFF TECHNICAL payroll no name length of service level grade project  O

Specialisation & Generalisation Relationships EMPLOYEE STUDENT PERSON O name salary fee  d RESEARCH TEACHING POST GRAD UNDER thesis LECTURING TUTORS address project FINAL YEAR year = 3 SUPERVISOR 1-2 courseno

Specialisation Lattice with Shared Subclass To be a shared subclass the superclasses must have the same key, so any of the options A, B or C stand. Staff payroll no Academic Admin Technical  d Manager Admin Manager Hourly Staff Salaried Staff

Categories and Categorisation A category is a subclass of the union of two or more superclasses that can have different keys because they can be of different entity types If defining superclasses have different keys, specify a new surrogate key COMPANY PERSON personid compid U  OWNER( ??? ) PERSON( ??? ) COMPANY( ??? ) duration of ownership OWNER

Entity Constraints If an entity instance X depends on the existence of an entity instance Y, then X is existence dependent on entity type Y is dominant entity type X is subordinate

Strong and Weak Entities (identifier dependency) a strong entity type has an identifying primary key a weak entity type does not have a primary key but does have a discriminator customer CUSTOMER address 1 CUST-ORDER m orderid ORDER date

Weak Entity customer CUSTOMER address CUST-ORDER orderid date 1 LINES part quantity ORDER_ ORDER-MAKEUP 1 m CUSTOMER address orderid date CUST-ORDER customer

Mapping Weak Entities to Relations Create a relation consisting of: n U primary_key(Ei) U partial_key U {ai…an} i=1 Primary key of each participating identifying entity type Attributes of the weak entity type (if any) Partial key of weak entity (if any) CUSTOMER address orderid date ORDER CUST-ORDER 1 m customer

Association Entity Type An entity type that represents an association relationship type Useful if: a relationship has lots of attributes you want a relationship type with a relationship type STUDENT COURSE labmark exammark ENROL m n TUTOR STAFF

Association Entity Type plus Mapping An entity type that represents an association relationship type COURSE labmark exammark ENROL m name given family STUDENT subject equip studno courseno STUD_ENROL COURSE_ENROL 1 COURSE(courseno, subject, equip) STUDENT(studno, givenname, familyname )

Aggregation (Count, Sum, Max, Avg) Aggregation is an abstraction concept for building composite entities from their components 1. aggregate attribute values to form a whole entity 2. combining entities that are related by an association relationship into higher-level aggregate entity IS-A-PART-OF IS-A-COMPONENT-OF Sadly, not catered for in EER modelling.

Aggregation STUDENT ENROL COURSE COURSE TUTORIAL STAFF studno courseno slot COURSE TUTORIAL TUTORS STAFF

Hints for EER Modelling identify entity types by searching for nouns and noun phrases assume all entities are strong and check for weak ones on a later pass need an identifier for each strong entity assume all relationships are partial participation (optional) and check for total (mandatory) ones on a later pass expect to keep changing your mind about whether things are entities, relationships or attributes keep level of detail relevant and consistent (for example leave out attributes at first) approach diagram through different views and merge them

Lets Practice! A record company wishes to use a computer database to help with its operations regarding its performers, recordings and song catalogue. Songs have a unique song number, a non-unique title and a composition date. A song can be written by a number of composers; the composer’s full name is required. Songs are recorded by recording artists (bands or solo performers). A song is recorded as a track of a CD. A CD has many songs on it, called tracks. CDs have a unique record catalogue number, a title and must have a producer (the full name of the producer is required). Each track must have the recording date and the track number of the CD. A song can appear on many (or no) CDs, and be recorded by many different recording artists. The same recording artist might re-record the same song on different CDs. A CD must have only 1 recording artist appearing on it. CDs can be released a number of times, and each time the release date and associated number of sales is required.