Sunday, June 28, 2015 1 Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Chapter 6: Entity-Relationship Model (part I)
the Entity-Relationship (ER) Model
Prof. Sin-Min Lee Department of Computer Science
Mapping ER to Relational Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Text-Book Chapters (7 and 8) Entity-Relationship Model
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
Databases Revision.
Final Exam Revision 5 Prof. Sin-Min Lee Department of Computer Science.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Chapter 3: Relational Model
Enhanced ER-diagram Prof. Sin-Min Lee Department of Computer Science.
Chapter 2: Entity-Relationship Model (Continued)
Database Design & ER Diagrams
Entity-Relationship Model
ER- and EER-to-Relational Mapping
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
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.
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Entity-Relationship Model
Page 1 Topic 3 ER Model Chapter 14 of the date’s book Chapter 3 and 4 of Elmasri’s book CPS510 Database Systems Abdolreza Abhari School of Computer Science.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 6: Entity-Relationship Model.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
Entity Relationship Diagram (2)
DATABASE MANAGEMENT SYSTEM Entity-Relationship Model.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Databases Illuminated Chapter 3 The Entity Relationship Model.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
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.
Data Modeling Using the Entity-Relationship (ER) Data Model.
CST203-2 Database Management Systems Lecture 4. Student entity NIDFNameLNameRegNoExamIdBirthdate.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module 8: Entity-Relationship.
Chapter 2: Entity-Relationship Model. 3.2 Chapter 2: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
IT 5433 LM2 ER & EER Model. Learning Objectives: Explain importance of data modeling Define and use the entity-relationship model Define E/R terms Describe.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
ER Diagrams and Relational Model CS 174a (Winter 2015)
Chapter 2: Entity-Relationship Model
Data Modeling Using the Entity- Relationship (ER) Model
COP Introduction to Database Structures
Relational Database Design by ER- and EER-to- Relational Mapping
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Outline of the ER Model By S.Saha
Chapter 6: Entity-Relationship Model
Presentation transcript:

Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)

Sunday, June 28, E-R MODEL E-R model is based on a real world that consists of entities and relationships. It consists of two primitives: 1.Entities: objects that exist and are distinguishable from one another. These objects might be abstract, e.g., SF-49ers, Joe, Bob, etc. 2.Relationships: two or more entities may participate in a relationship, e.g., Joe is a fan of SF-49ers, etc. An entity is represented by a set of attributes, e.g., Joe might have a social- security number, a phone number, a spouse, and a salary An attribute is a function that maps an entity into a domain, e.g., Joe's social- security number maps Joe into the domain of integers. An attribute is represented as an A set of entities of the same type is termed an entity set, e.g., football teams. Entity sets do not need to be disjoint, e.g., students, employees, people. An entity set is represented as a

Sunday, June 28, RELATIONSHIPS Relationships of the same type are contained in a relationship set. More formally, if E 1, E 2,..., E n are entity sets, then a relationship set R is a subset of:{(e 1, e 2,..., e n ) | e 1 ∈ E 1, e 2 ∈ E 2,..., e n ∈ E n } where (e 1, e 2,..., e n ) is a relationship. A relationship set is represented as a A relationship may involve two entities, binary relationship: A relationship may involve three entities, ternary relationship: Football Teams fans People Football Teams fans People Date

Sunday, June 28, A relationship does not require participation of entities from a set. In the previous example, John as an entity in “People” entity-set and is not required to participate in a relationship with “Football Teams” entity-set. There are times, when one may want to specify that all members of an entity set MUST participate in a relationship. Use double lines to represent this case. The double lines specifies total participation of entities in People entity set in the “fans” relationship set. RELATIONSHIPS Football Teams fans People

Sunday, June 28, RELATIONSHIPS (Cont…) A relationship may involve n entities, N-ary relationship It is always possible to replace a non-binary relationship set by a number of distinct binary relationship sets Football Teams fans People Date on

Sunday, June 28, RELATIONSHIPS (Cont…) Example: A library database contains a listing of authors that have written books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects.

Sunday, June 28, RELATIONSHIPS (Cont…) Example: A library database contains a listing of authors that have written books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects. Entity sets: authors, subjects, books, libraries

Sunday, June 28, RELATIONSHIPS (Cont…) Example: A library database contains a listing of authors that have written books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects. Entity sets: authors, subjects, books, libraries Relationship sets: wrote, carry, indexed E-R diagram: carry books indexwrote subjectauthors SS# name title libraries quantity address isbn Subject matter

Sunday, June 28, BINARY RELATIONSHIP A binary relationship between entity set A and B might be: 1:1 Women marrying Men (function) N:1 Children having mothers (function) 1:N Mothers having children (inverse function) M:N Students enrolled in a class women marry men children having mothers having children students enrolled classes 1 n n1 A B A B A B A B

Sunday, June 28, KEY Entities and relationships are distinguishable using various keys A key is a combination of one or more attributes, e.g., social-security number, combination of name and social-security number. A superkey is a key defined either for an entity set or relationship set that uniquely identifies an entity, e.g., social-security number, phone number, combination of name and social-security number. A candidate key is a minimal superkey that uniquely identifies either an entity or a relationship, e.g., social-security number, phone number. A primary key is a candidate key that is chosen by the database designer to identify the entities of an entity set.

Sunday, June 28, KEY (Cont…) A foreign key is a set of one or more attributes of a strong entity set that are employed to construct the discriminator of a weak entity set. The primary key of a weak entity set is formed by the primary key of the strong entity set on which it is existence-dependent. Relationship sets also have primary keys. Assume R is a relationship set involving entity sets E 1, E 2,..., E n. Let primary-key(E i ) denote the primary key for entity set E i. Assume primary-key(E i ) is unique for 1 ≤ i ≤ n. If R has no attributes then its superkey is: primary-key(E 1 ) ∪ primary-key(E 2 ) ∪... ∪ primary-key(E n ) This is a primary key if the mapping constraint is many-to-many. If the mapping constraint is many to one from E 1 to E 2 then the primary key of R is primary key of E 1. books wrote authors SS# name title edition E1E1 R E2E2

Sunday, June 28, EXAMPLE Employees of a large company, e.g., IBM, where an employee reports to a manager. The manager is also an employee who reports to another manager. This chain of command continues to the very top where the CEO is the only employee who is not reporting to a manager. Draw the ER diagram for this example.

Sunday, June 28, GENERALIZATION AND SPECIALIZATION Generalization is the result of computing the union of two or more entity sets to produce a higher-level entity set. It represents the containment relationship that exists between the higher-level entity set and one or more lower-level entity sets. Specialization constructs the lower level entity sets that are a subset of a higher level entity set. sid student name is A graduate Undergrad Specialization Generalization

Sunday, June 28, GENERALIZATION AND SPECIALIZATION Undergrad and graduate are termed subclasses of the superclass student. This is a superclass/subclass or simply class/subclass relationship. A member of a subclass MUST be a member of the superclass. An alternative notation is the Union symbol The circle with d specifies that the specializations are disjoint. A member of Undergrad entity set may NOT be a member of the graduate entity set. sid student name graduate Undergrad Specialization Generalization d U U

Sunday, June 28, GENERALIZATION AND SPECIALIZATION A design may require all members of an entity-set to be specialized. For example, an employee MUST be a member of either a Salaried or Part-time. Use double lines to dictate this constraint. sid Emp name Part-time Salaried Specialization Generalization d U U

Sunday, June 28, GENERALIZATION AND SPECIALIZATION One may allow the specialized entity sets to overlap. For example, an entity might be both a Salaried and Part-time. “o” stands for Overlap when specializing. sid Emp name Part-time Salaried Specialization Generalization o U U

Sunday, June 28, Relational Data Model (Chapter 7)

Sunday, June 28, BASIC CONCEPTS Relational data model consists of a collection of tables, each with a unique name. A table is termed a relation. A row (also termed a tuple or a record) in table R represents a relationship among a set of values. Each value corresponds to an attribute or a field. A column of a table represents an attribute. Given a relation with attributes (A 1 :D 1, A 2 :D 2,..., A n :D n ) the domain of this relation is D 1 × D 2 ×.... × D n. However, an instance of a relation is a subset of this domain (recall “value & a variable”), e.g., CSCI485 (stid:integer, name:string, gpa:float) 101Adams Jones Hayes Smith3.1 stidnamegpa

Sunday, June 28, A tuple variable t refers to a tuple in the relation. One may access the value of an attribute contained in a tuple variable by t[attr-name]. e.g., t[stid] t[stid] = 101t[name] = “Hayes” t[1] = 102 Database scheme is the data about the data. It describes the logical design of the database. student-schema = (stdid, name, gpa) schema for relation student CSCI485(student-schema) CSCI485 is a relation on student-schema Database instance is the data in the database at a given instant in time. Entity and relationship sets are represented by relations

Sunday, June 28, TABLES GENERATION Transforming an entity set to a table (relation): 1.Strong entity set with attributes a 1, a 2,..., a n : represent it as a table with n unique columns (one column per attribute). 2.Weak entity set with attributes a 1, a 2,..., a n and a foreign key b 1, b 2,..., b m : represent it as a table with n+m columns, one for each of {a 1, a 2,..., a n } ∪ {b 1, b 2,..., b m }. Transforming relationship sets to tables: 1.Relationship set involving entity sets E 1, E 2,..., E n, each entity having primary key prim-key(E i ), represent it as a relation with each attribute corresponding to – ∪ Prim_key(E i ) 2.if the relationship has attributes a 1, a 2,..., a n then the relation consists of: –{a 1, a 2,..., a n } ∪ ∪ Prim_key (E i ) i=1 n n

Sunday, June 28, For a functional relationship (1:1, M:1, 1:M) from set A to set B, incorporate the primary key of B into A Author(SS#, name, phone) Book(SS#, isbn, title) The number of attributes in a relation R is termed arity or degree of relation R. The number of tuples in a relation R is termed the cardinality of R. TABLES GENERATION (Cont…) SS# name phone isbn title authorbook wrote

Sunday, June 28, TABLES GENERATION (Cont…) For specialization and generalization: SS# Person name is A Emp Student gpa salary

Sunday, June 28, TABLES GENERATION (Cont…) Two ways to generate tables: 1.Approach 1: A table for the higher level entity set For each lower entity set, create a table that includes a column for each of the attributes of that entity set plus a column for each attribute of the primary key of the higher-level entity set Person(SS#, name) Student(SS#, gpa) Emp(SS#, salary) 2.Approach 2: No table for the higher level entity set One table for each lower entity set with the following columns:  One column for each local attribute  One column for each attribute of the higher level set Student(SS#, name, gpa) Emp(SS#, name, salary)