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

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

Chapter 2: Entity-Relationship Model

Chapter 6: Entity-Relationship Model

Chapter 6: Entity-Relationship Model

Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the Bank Database Reduction to

Chapter 6: Entity-Relationship Model

Lecture 14 of 42. E-R Diagrams, UML Notes: PS3 Notes, E-R Design. Thursday, 15 Feb 2007

Example: specific person, company, event, plant

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

DATABASE TECHNOLOGY - 1DL124

6.1 RELATIONSHIP CONCEPTS

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

DATABASE DESIGN I - 1DL300

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

Chapter 2: Relational Model

Intro to DB CHAPTER 6

Database System Concepts

Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

DATABASE TECHNOLOGY. Spring An introduction to database systems

CSIT5300: Advanced Database Systems

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

CSIT5300: Advanced Database Systems

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

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

Chapter 6: Entity-Relationship Model

UNIT II A. ENTITY RELATIONSHIP MODEL

Chapter 3: Relational Model

Chapter 7: Entity-Relationship Model

COMP Instructor: Dimitris Papadias WWW page:

CS34800 Information Systems. The Relational Model Prof. Walid Aref 29 August, 2016

The Entity Relationship Model

CMSC 424 Database design Lecture 4: Relational Model ER to Relational model. Book: Chap. 2 and 6. Mihai Pop

Chapter 2: Relational Model

CSE 132A Database Systems Principles

The En'ty Rela'onship Model

CSCC43H: Introduction to Databases

Database System Concepts, 5 th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "

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

Conceptual Data Modeling

Database Management Systems LECTURE NOTES 2

2. E-R Model. Entity Sets Relationship Sets Attributes

CSCI1270 Introduction to Database Systems

DBMS: AN INTERACTIVE TUTORIAL

ENTITY-RELATIONSHIP MODEL III. CS121: Relational Databases Fall 2017 Lecture 16

Unit I. By Prof.Sushila Aghav MIT

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

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

The Entity-Relationship (ER) Model 2

Major components of ER diagram Practices

Topic 5: Mapping of EER Diagrams to Relations


COMP102: Introduction to Databases, 9.1

VARDHAMAN COLLEGE OF ENGINEERING Shamshabad , Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS

SE 4DB3 TUTORIAL 2: REDUCTION TO RELATIONAL SCHEMAS

Chapter 2 Introduction to Relational Models

Unit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Contents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model

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

FINAL EXAM REVIEW. CS121: Introduction to Relational Database Systems Fall 2018 Lecture 27

Chapter 2 Conceptual Modeling. Objectives

DATABASE SCHEMA DESIGN ENTITY-RELATIONSHIP MODEL. CS121: Relational Databases Fall 2017 Lecture 14

Database Management System 6 ER Modeling...

CMSC 424 Database design Lecture 3: Entity-Relationship Model. Book: Chap. 1 and 6. Mihai Pop

Database Design and the E-R Model (7.4, )

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Represent entities and relations with diagrams

Database Systems. Answers

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

Upon completion of this Unit, students will be introduced to the following

Conceptual Design. The Entity-Relationship (ER) Model

E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

Chapter 4. The Relational Model

Ch.6 DB design. Why design? Pitfalls at the two extremes: Redundancy Incompleteness. Two strategies: Bottom-up Top-down. Ch.6 is devoted to bottom-up

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

1. (a) Explain the Transaction management in a database. (b) Discuss the Query Processor of Database system structure. [8+8]

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

Entity-Relationship Model &

Lecture 10 - Chapter 7 Entity Relationship Model

Relational Model (cont d) & Entity Relational Model. Lecture 2

High Level Database Models

How to translate ER Model to Relational Model

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

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

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017

Database Management System 10 Conversion of ER model to Relational Model

Database Management System by

Data about data is database Select correct option: True False Partially True None of the Above

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

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

ER to Relational Mapping

Relational Model. CS 377: Database Systems

Lecture3: Data Modeling Using the Entity-Relationship Model.

U1. Data Base Management System (DBMS) Unit -1. MCA 203, Data Base Management System

Objectives Definition iti of terms Importance of data modeling Write good names and definitions for entities, relationships, and attributes Distinguis

Transcription:

The Relational Model Lecture 2 The Entity-Relationship Model and its Translation to the Relational Model Entity-Relationship (ER) Model + Entity Sets + Relationship Sets + Database Design Issues + Mapping Constraints + Keys + ER Diagrams Chapter 2 (Sections 2.3, 2.4, 2.5, 2.6, 2.8, 2.9) Relational Model Translation of ER-model into the Relational Model 2 Database Modeling: Chaos! Entity Sets dependants, and the person-number of the employee s manager. The bank also keeps track of the employee s start date and, thus, the length of employment. A database can be modeled as: + a collection of entities, + a set of relationships among entities. An entity is an object that exists and is distinguishable from other objects. Examples: specific person, company, event, plant Entities have attributes Examples: people have names and addresses An entity set is a set of entities of the same type that share the same properties. Examples: set of all persons, companies, trees, holidays 3 4 Attributes Relationship Sets An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. customer = (customer-id, customer-name, customer-street, customer-city) loan = (loan-number, amount) A relationship is an association among several entities Example: Hayes depositor A-102 customer entity relationship set account entity Domain the set of permitted values for each attribute A relationship set is a mathematical relation among n 2 entities, Attribute types: + Simple and composite attributes. + Single-valued and multi-valued attributes E.g. multivalued attribute: phone-numbers + Derived attributes each taken from entity sets {(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 + Example: (Hayes, A-102) depositor Can be computed from other attributes E.g. age, given date of birth 5 6 1

Relationship Sets (Cont.) An attribute can also be property of a relationship set. For instance, the depositor relationship set between entity sets customer and account may have the attribute access-date Degree of a Relationship Set Refers to number of entity sets that participate in a relationship set. Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary. Relationship sets may involve more than two entity sets. + E.g. Suppose employees of a bank may have tasks (responsibilities) at multiple branches, with different tasks at different branches. Then there is a ternary relationship set between entity sets employee, task, and branch. 7 8 Design Issues & Decisions Mapping Cardinalities Use of entity sets vs. attributes + Choice mainly depends on the structure of the enterprise being modeled, and on the semantics associated with the attribute in question. Express the number of entities to which another entity can be associated via a relationship set. Most useful in describing binary relationship sets. Use of entity sets vs. relationship sets + Possible guideline is to designate a relationship set to describe an action that occurs between entities Binary versus n-ary relationship sets + Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set by a number of distinct binary relationship sets, a n-ary relationship set shows more clearly that several entities participate in a single relationship. For a binary relationship set the mapping cardinality must be one of the following types: + One to one + One to many + Many to one + Many to many 9 10 Mapping Cardinalities Mapping Cardinalities One to one One to many Many to one Many to many Some elements in A and B may not be mapped to any element in the other set Some elements in A and B may not be mapped to any element in the other set 11 12 2

Keys Keys for Relationship Sets A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity. A candidate key of an entity set is a minimal super key + Person-number is candidate key of customer + Account-number is candidate key of account Although several candidate keys may exist, one of the candidate keys is selected to be the primary key. The combination of primary keys of the participating entity sets forms a super key of a relationship set. + (customer-id, account-number) is the super key of depositor To decide what are the candidate keys: + Must consider the mapping cardinality of the relationship set + Need to consider semantics of relationship set in selecting the primary key in case of more than one candidate key 13 14 Weak Entity Sets E-R Design Decisions 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 existence of an identifying entity set + it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set + identifying relationship depicted using a double diamond The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities 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 the weak entity set is existence dependent, plus the weak entity set s discriminator. The use of an attribute or entity set to represent an object. Whether a real-world concept is best expressed by an entity set or a relationship set. The use of a ternary relationship versus a pair of binary relationships. The use of a strong or weak entity set. 15 16 Database Modeling: Identifying Entities DB Modeling: Identifying Relationships dependants, and the person-number of the employee s manager. The bank also keeps track of the employee s start date and, thus, the length of employment. dependants, and the person-number of the employee s manager. The bank also keeps track of the employee s start date and, thus, the length of employment. 17 18 3

DB Modeling: Identifying Attributes E-R Diagram for a Banking Enterprise dependants, and the person-number of the employee s manager. The bank also keeps track of the employee s start date and, thus, the length of employment. 19 20 Relational Model: Basic Structure Attribute Types Formally, given sets D 1, D 2,. D n a relation r is a subset of Each attribute of a relation has a name. D 1 x D 2 x x D n Thus a relation is a set of n-tuples (a 1, a 2,, a n ) where a i D i The set of allowed values for each attribute is called the domain of the attribute. Example: if customer-name = {Jones, Smith, Curry, Lindsay} customer-street = {Main, North, Park} customer-city = {Harrison, Rye, Pittsfield} Attribute values are (normally) required to be atomic, that is, indivisible + E.g. multivalued (set) attribute values are not atomic + E.g. composite attribute values are not atomic Then r = { (Jones, Main, Harrison), (Smith, North, Rye), (Curry, North, Rye), (Lindsay, Park, Pittsfield) } is a relation over customer-name x customer-street x customer-city 21 22 Reduction of an E-R Schema to Tables Primary keys allow entity sets and relationship sets to be expressed uniformly as tables which represent the contents of the database. Representing Entity Sets as Tables A strong entity set reduces to a table with the same attributes. A database which conforms to an E-R diagram can be represented by a collection of tables. For each entity set and relationship set there is a unique table which is assigned the name of the corresponding entity set or relationship set. Each table has a number of columns (generally corresponding to attributes), which have unique names. Converting an E-R diagram to a table format is the basis for deriving a relational database design from an E-R diagram. 23 24 4

Composite and Multivalued Attributes Representing Weak Entity Sets Composite attributes are flattened out by creating a separate attribute for each component attribute + E.g. given entity set customer with composite attribute name with component attributes first-name and last-name the table corresponding to the entity set has two attributes name.first-name and name.last-name A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set A multivalued attribute M of an entity E is represented by a separate table EM + Table EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M + E.g. Multivalued attribute dependent-names of employee is represented by a table employee-dependent-names( employee-id, dname) + Each value of the multivalued attribute maps to a separate row of the table EM 25 26 Representing Relationship Sets as Tables Redundancy of Tables A many-to-many relationship set is represented as a table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. E.g.: table for relationship set borrower Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the many side, containing the primary key of the one side. E.g.: Instead of creating a table for relationship account-branch, add an attribute branch to the entity set account 27 28 Redundancy of Tables (Cont.) Keys For one-to-one relationship sets, either side can be chosen to act as the many side + That is, extra attribute can be added to either of the tables corresponding to the two entity sets If participation is partial on the many side, replacing a table by an extra attribute in the relation corresponding to the many side could result in null values The table corresponding to a relationship set linking a weak entity set to its identifying strong entity set is redundant. + E.g. The payment table already contains the information that would appear in the loan-payment table (i.e., the columns loan-number and payment-number). Let K R K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(r) by possible r we mean a relation r that could exist in the enterprise we are modeling. Example: {customer-name, customer-street} and {customer-name} are both superkeys of Customer, if no two customers can possibly have the same name. K is a candidate key if K is minimal Example: {customer-name} is a candidate key for Customer, since it is a superkey {assuming no two customers can possibly have the same name), and no subset of it is a superkey. 29 30 5

Determining Keys from E-R Sets Schema Diagram for the Banking Enterprise Strong entity set. The primary key of the entity set becomes the primary key of the relation. Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set. Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. + For binary many-to-one relationship sets, the primary key of the many entity set becomes the relation s primary key. + For one-to-one relationship sets, the relation s primary key can be that of either entity set. + For many-to-many relationship sets, the union of the primary keys becomes the relation s primary key 31 32 6