Fundamentals of Databases CSU 07203

Slides:



Advertisements
Similar presentations
Chapter 6: Entity-Relationship Model (part I)
Advertisements

Entity-Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
ENTITY RELATIONSHIP MODELLING
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Systems Development Life Cycle
Text-Book Chapters (7 and 8) Entity-Relationship Model
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
System Analysis - Data Modeling
Systems Analysis Requirements structuring Process Modeling Logic Modeling Data Modeling  Represents the contents and structure of the DFD’s data flows.
Chapter 3: Modeling Data in the Organization
Chapter 3 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Importance of data modeling Importance of data modeling Write good.
Modern Systems Analysis and Design Third Edition
Entity/Relationship Modelling
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Chapter 2: Modeling Data in the Organization
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Rob and Coronel Adapted for INFS-3200.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization.
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Data Modeling Using the Entity-Relationship (ER) Model.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
ERD ( Conceptual data model From the statement of data requirements a conceptual data model is produced. This describes.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
2 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Data Models Why data models are important About the basic data-modeling.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
IS 4420 Database Fundamentals Chapter 3: Modeling Data in the Organization Leon Chen.
Chapter 2: Entity-Relationship Model
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
Entity Relationship Modeling
Chapter 10 Structuring System Requirements: Conceptual Data Modeling
Entity/Relationship Modelling
Business System Development
Entity-Relationship Model
Data Modeling Using the Entity- Relationship (ER) Model
Entity-Relationship Model
TMC2034 Database Concept and Design
Entity Relationship Model
Chapter 6 Structuring System Requirements: Conceptual Data Modeling
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Outline of the ER Model By S.Saha
Lecture3: Data Modeling Using the Entity-Relationship Model.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Overview of Entity‐Relationship Model
Entity Relationship Diagrams
Chapter 4 Entity Relationship (ER) Modeling
Entity-Relation Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 10 Structuring System Requirements: Conceptual Data Modeling
Review of Week 1 Database DBMS File systems vs. database systems
Chapter 3: Modeling Data in the Organization
Chapter 7: Entity-Relationship Model
Chapter 10 Structuring System Requirements: Conceptual Data Modeling
ER MODELING Instructor: SAMIA ARSHAD
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Lecture 10 Structuring System Requirements: Conceptual Data Modeling
Presentation transcript:

Fundamentals of Databases CSU 07203 The Institute of Finance Management FCIM BCS & BIT Year I -2016/2017 Entity Relationship (ER) Model

Entity Relationship (ER) Model Logistics Instructor: Siphy, A. S(Mr.) email: dullextz@gmail.com Office: Block D, 020 Consultation Time Thursdays 14:00 -15:00 HRS Or By appointment Entity Relationship (ER) Model

Entity Relationship (ER) model References; Elmasri/Navathe: Fundamentals of DB system, 4th Ed, Ch. 3-5, ) Rob/Cornel: Database systems 6 ed. Entity Relationship (ER) Model

Data Modeling Using the Entity-Relationship (ER) Model

Entity Relationship (ER) Model In this lecture; ER models Entities Relationships Attributes Business rules ER Diagrams (ERDs) Entity Relationship (ER) Model

Entity Relationship (ER) Model Objectives To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated into the database design process. To describe how ERD components affect database design and implementation. Entity Relationship (ER) Model

Entity Relationship (ER) Model Objective.. Describe the Conceptual Database Design Describe Major components of ER diagram Compare and evaluate given ER-diagrams. Evaluate the significance of the ER-model for DB design. Describe why understanding of organizational data is important. Argue why unambiguous representation of data in logical terms is needed for implementing a database that will effectively serve the needs of management Understanding the business rules Entity Relationship (ER) Model

Database Design Before we look at how to create and use a database we’ll look at how to design one Need to consider What tables, keys, and constraints are needed? What is the database going to be used for? Conceptual design Build a model independent of the choice of DBMS hardware platform that is used to implement the database Logical design Create the database in a given DBMS Physical design How the database is stored in hardware Entity Relationship (ER) Model

What is Conceptual Database Design? Process of describing the data, relationships between the data and the constraints on the data. After analysis - Gather all the essential data required and understand how the data are related The focus is on the data, rather than on the processes. The output of the conceptual database design is a Conceptual Data Model ( + Data Dictionary) Entity Relationship (ER) Model

Gathering Information for Conceptual Data Modeling Two perspectives Top-down Data model is derived from an intimate understanding of the business. Bottom-up Data model is derived by reviewing specifications and business documents. Entity Relationship (ER) Model

Entity-Relationship (ER) Modeling. 1976 proposed by Peter Chen ER Modelling is used for conceptual database design a top-down approach to database design. The basic concepts of the E-R model include.. Entity types Relationship types and Attributes Entity Relationship (ER) Model

Entity Relationship (ER) Model E-R Modeling (Cont.) ER Models are often represented as ER diagrams (ERDs) ERD is widely used in database design Represents conceptual level of a database system Describes things and their relationships in high level Can identify some problems in a design The ERDs represent three main components Entities, Attributes & Relationships ERD example Lecturer ID Name Course Tutors Student Studies Module Entity Relationship (ER) Model

Entities Entities represent objects or things of interest Physical things like students, lecturers, employees, products More abstract things like modules, orders, courses, projects Entity Relationship (ER) Model

Entity Relationship (ER) Model Entity type & Sets Entities have a general type /class called entity type. Entity type a class of entities that have the same set of attributes An entity set is a set of entities of the same type that share the same properties. Example: set of all persons, companies, trees, holidays Entity Relationship (ER) Model

Entity Relationship (ER) Model Entities… More examples of entities: Person: EMPLOYEE, STUDENT, PATIENT Place: STORE, WAREHOUSE Object: MACHINE, PRODUCT, CAR Event: SALE,REGISTRATION, RENEWAL Concept: ACCOUNT, COURSE Guidelines for naming and defining entity types: An entity type name is a singular noun An entity type should be descriptive and specific and concise Event entity types should be named for the result of the event, not the activity or process of the event. Entity Relationship (ER) Model

Diagramming Entities - example In an ER Diagram, an entity is usually drawn as a box with rounded corners/ rectangular shape The box is labelled with the name of the class of objects represented by that entity Lecturer ID Name Course Tutors Student Studies Module Diagramming Entities - example Entity Relationship (ER) Model

Attributes Attributes are facts, aspects, properties, or details about an entity Attributes have A name An associated entity Domains of possible values Values from the domain for each instance of the entity they are belong to Entity Relationship (ER) Model

Entity Relationship (ER) Model Attributes.. Example of entity types and associated attributes: STUDENT: Student_ID, Student_Name, Home_Address, Phone_Number, Major Guidelines for naming attributes: An attribute name is a noun. An attribute name should be unique To make an attribute name unique and clear, each attribute name should follow a standard format Similar attributes of different entity types should use similar but distinguishing names. Entity Relationship (ER) Model

Diagramming Attributes In an ER Diagram attributes may be drawn as ovals Each attribute is linked to its entity by a line The name of the attribute is written in the oval Lecturer ID Name Course Tutors Student Studies Module Entity Relationship (ER) Model

Entity Relationship (ER) Model Attributes -Types An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. Classifications of attributes: Required vs. Optional Attributes Simple vs. Composite Attribute Single-Valued vs. Multivalued Attribute Stored vs. Derived Attributes Identifier Attributes - keys Attribute types: Simple and composite attributes. Single-valued and multi-valued attributes E.g. multi-valued attribute: phone-numbers, project, hobby and so on Derived attributes Can be computed / derived from other attributes E.g. age, given date of birth Entity Relationship (ER) Model

Required vs. Optional Attributes Example: entity – ONLINE_ACCOUNT Required attributes (Not NULL) Account_ID Password Owner_Name Optional attributes (NULL) Phone_Number Password_Hint Entity Relationship (ER) Model

Entity Relationship (ER) Model Figure 1 – A composite attribute Composite: Is an attribute composed of multiple components, each with an independent existence Composite attribute An attribute broken into component parts component attributes Entity Relationship (ER) Model 12

Entity Relationship (ER) Model Figure 2 – Entity with a Multivalued attribute (Skill) and derived attribute (Years_Employed) Multivalued: Is one that holds multiple values for a single entity Derived: is one that represents a value that is derivable from the value of a related attribute or set of attributes , not necessarily in the same entity Derived from date employed and current date Multivalued: an employee can have more than one skill Entity Relationship (ER) Model 13

Entity Relationship (ER) Model Figure 3 – An attribute that is both Multivalued and composite Entity Relationship (ER) Model 37

Entity Relationship (ER) Model Identifiers (Keys) Identifier (Key) - An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type Candidate Key – an attribute that could be a key. Examples (for STUDENT, PERSON)? Simple Key versus Composite Key Entity Relationship (ER) Model 6

Entity Relationship (ER) Model Figure 4 Simple key attribute The key is underlined Entity Relationship (ER) Model 14

Entity Relationship (ER) Model Figure 5 Composite key attribute Flight_Number Date Entity Relationship (ER) Model 15

Relationship name: writes Relationships Associations between instances of one or more entity types that is of interest Given a name that describes its function. relationship name is an active or a passive verb. Relationship name: writes Book Author An author writes one or more books A book can be written by one or more authors. Entity Relationship (ER) Model

Entity Relationship (ER) Model Relationships.. Relationships have A name A set of entities that participate in them A degree - the number of entities that participate (most have degree 2) A cardinality ratio Entity Relationship (ER) Model

Diagramming Relationships Relationships are links between two entities The name is given in a diamond box The ends of the link show cardinality Lecturer ID Name Course Tutors Student Studies Module One Many Entity Relationship (ER) Model

Cardinality and Connectivity Relationships can be classified as either One – to – One (1:1) One – to – Many(1:M) Many – to –Many(N:M) Cardinality : minimum and maximum number of instances of Entity B that can (or must be) associated with each instance of entity A. Connectivity Entity Relationship (ER) Model

Cardinality Ratios.. One to many (1:M) Many to many (M:M) Each entity in a relationship can participate in zero, one, or more than one instances of that relationship Three types of relationships (examples) One to one (1:1) Each lecturer has a unique office One to many (1:M) A lecturer may tutor many students, but each student has just one tutor Many to many (M:M) Each student takes several modules, and each module is taken by several students Entity Relationship (ER) Model

Cardinality and Connectivity… examples Professor teaches Class Professor Class teaches A professor teaches class OR A class is taught by professor How Many?? Entity Relationship (ER) Model

Cardinality and Connectivity…examples 1 M Professor teaches Class (1,4) (1,1) Cardinality Connectivity Professor Class teaches (1,1) (1,4) Cardinality Entity Relationship (ER) Model

ER Modeling Notations -summary Notation uses three main constructs Data entities Relationships Attributes Chen Model & Crow’s Foot Model Entity Relationship (ER) Model

Entity Relationship (ER) Model Chen Notation Association between the instances of one or more entity types EntityName Verb Phrase AttributeName named property or characteristic of an entity Person, place, object, event or concept about which data is to be maintained Represents a set or collection of objects in the real world that share the same properties Entity set Entity Relationship (ER) Model

Entity Relationship (ER) Model Crow’s Foot Notation Entity Attribute Relationship EntityName EntityName Verb phrase List of Attributes Acceptable Entity Relationship (ER) Model

Entity Relationship (ER) Model Connectivity Chen Model 1 to represent one. M to represent many Crow’s Foot 1 M Mandatory one , means (1,1) One many One or many Entity Relationship (ER) Model

Entity Relationship (ER) Model Relationships…. Relationship Type vs. Relationship Instance Degree of a relationship Cardinality of a relationship Associative Entity – combination of relationship and entity Entity Relationship (ER) Model

Entity Relationship (ER) Model Relationship Sets A relationship set is a mathematical relation among n  2 entities, each taken from entity sets {(e1, e2, … en) | e1  E1, e2  E2, …, en  En} where (e1, e2, …, en) is a relationship Example: (Hayes, A-102)  depositor Entity Relationship (ER) Model

Relationship Set borrower example Entity Relationship (ER) Model

Relationship Sets (Cont.) Entity Relationship (ER) Model

Entity Relationship (ER) Model Figure 6 –a relationship with an attribute attribute of the relationship The relationship type is modeled as the diamond and lines between entity types Entity Relationship (ER) Model 20

Entity Relationship (ER) Model Degree of a relationship is the number of entity types that participate in it Entities of two different types related to each other One entity related to another of the same entity type Entities of three different types related to each other Entity Relationship (ER) Model 8

Entity Relationship (ER) Model Degree of relationship -Examples Refers to number of entity sets that participate in a relationship set. It indicates the number of associated entities Entity Relationship (ER) Model

Cardinality of a Relationship One-to-One Each entity in the relationship will have exactly one related entity One-to-Many An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity Many-to-Many Entities on both sides of the relationship can have many related entities on the other side Entity Relationship (ER) Model

Cardinality of a Relationship-examples One to One One to Many One to One Note: Some elements in A and B may not be mapped to any elements in the other set Entity Relationship (ER) Model

Cardinality of a Relationship- examples Many to one Many to Many Note: Some elements in A and B may not be mapped to any elements in the other set Entity Relationship (ER) Model

Entity Relationship (ER) Model Figure 10 –Examples of relationships of different degrees –Unary relationships Entity Relationship (ER) Model 22

Entity Relationship (ER) Model Figure 11 –examples of relationships of different degrees –Binary relationships Entity Relationship (ER) Model 23

Entity Relationship (ER) Model Figure 12 –examples of relationships of different degrees –Ternary relationships Note: a relationship can have attributes of its own Entity Relationship (ER) Model 24

Cardinality Constraints Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity Minimum Cardinality. Examples? If zero, then optional If one or more, then mandatory Maximum Cardinality. Examples? The maximum number Entity Relationship (ER) Model 29

Entity Relationship (ER) Model Cardinalities Mandatory one Mandatory many Optional one Optional many 11 18 Entity Relationship (ER) Model

Entity Relationship (ER) Model Figure 13a –Basic relationship Figure 13b –Optional cardinalities with unary degree, one-to-one relationship Entity Relationship (ER) Model 1

Maximum Cardinality Constraint max cardinality constraint Entity Relationship (ER) Model 41

Entity Relationship (ER) Model Examples of multiple relationships –employees and departments Entities can be related to one another in more than one way Entity Relationship (ER) Model 40

Attributes or Relationship? Using relationships to link related attributes –composite, Multivalued attribute versus relationship Attributes can be transformed to relationships Entity Relationship (ER) Model

Entity Relationship (ER) Model Associative Entities It’s an entity – it has attributes AND it’s a relationship – it links entities together When should a relationship with attributes be an associative entity? All relationships for the associative entity should be many The associative entity could have meaning independent of the other entities The associative entity should have at least one or more attributes other than the identifier The associative entity may participate in other relationships other than the entities of the associated relationship Ternary relationships should be converted to associative entities Entity Relationship (ER) Model

Removing M:M Relationships Many to many relationships are difficult to represent We can split a many to many relationship into two one to many relationships An entity represents the M:M relationship Enrolment Student Module In Has Student Module Studies Entity Relationship (ER) Model

Entity Relationship (ER) Model An associative entity (CERTIFICATE) Entity Relationship (ER) Model 21

Entity Relationship (ER) Model Bill of materials structure Entity Relationship (ER) Model 27

Entity Relationship (ER) Model Figure ; Ternary relationship as an associative entity Entity Relationship (ER) Model 36

Strong vs. Weak Entities Strong entities exist independently of other types of entities has its own unique identifier represented with single-line rectangle Weak entity dependent on a strong entity…cannot exist on its own does not have a unique identifier represented with double-line rectangle Identifying relationship links strong entities to weak entities represented with double line diamond Entity Relationship (ER) Model

Figure ; Example of a weak entity and its identifying relationship -ER notation Strong entity Identifying relationship Weak entity

Entity Relationship (ER) Model Basic E-R notation Relationship symbols Attribute symbols Entity symbols A special entity that is also a relationship Relationship degrees specify number of entity types involved Relationship cardinalities specify how many of each entity type is allowed Entity Relationship (ER) Model 8

Entity Relationship (ER) Model Sample E-R Diagram Attribute Supplier_ID Supplier_Name Supplier_Address Entity Relationship (ER) Model 3

Entity Relationship (ER) Model Design Issues Identify business rules Construct ERD 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. 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 non-binary (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. Placement of relationship attributes Entity Relationship (ER) Model

Making ER Models To make an E/R model you need to identify Entities Attributes Relationships Cardinality ratios from a description General guidelines Since entities are things or objects they are often nouns in the description Attributes are facts or properties, and so are often nouns also Verbs often describe relationships between entities Entity Relationship (ER) Model

Entity Relationship (ER) Model Business Rules Brief, precise, and unambiguous descriptions of a policies, procedures, or principles within a specific organization Apply to any organization that stores and uses data to generate information Description of operations that help to create and enforce actions within that organization’s environment Entity Relationship (ER) Model

Business Rules (continued) Must be rendered in writing Must be kept up to date Sometimes are external to the organization Must be easy to understand and widely disseminated Describe characteristics of the data as viewed by the company Entity Relationship (ER) Model

Discovering Business Rules Sources of Business Rules: Company managers Policy makers Department managers Written documentation Procedures Standards Operations manuals Direct interviews with end users Entity Relationship (ER) Model

Discovering Business Rules (continued) Generally, Nouns translate into entities Verbs translate into relationships among entities Relationships are bi-directional Entity Relationship (ER) Model

Business Rules Examples - ER Diagrams Draw the ERD for the following scenarios: Each patient has one or more patient histories; each instance of patient history belongs to one patient. An employee may be recorded as having many jobs; a particular job may be recorded as having been held by many employees. A customer may place many orders; an order is specific to one customer. Entity Relationship (ER) Model

Example A university consists of a number of departments. Each department offers several courses. A number of modules make up each course and a module can be part of many courses. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship (ER) Model

Example - Entities A university consists of a number of departments. Each department offers several courses. A number of modules make up each course and a module can be part of many courses. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship (ER) Model

Example - Relationships A university consists of a number of departments. Each department offers several courses. A number of modules make up each course and a module can be part of many courses. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student Entities: Department, Course, Module, Lecturer, Student Department Course Module Lecturer Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student Each department offers several courses Offers Department Course Module Lecturer Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student A number of modules make up each courses Offers Department Includes Course Module Lecturer Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student Students enrol in a particular course Offers Department Includes Course Module Lecturer Enrols In Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student Students … take modules Offers Department Includes Course Module Lecturer Takes Enrols In Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student Each module is taught by a lecturer Offers Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student a lecturer from the appropriate department Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship (ER) Model

Example - E/R Diagram Department Course Module Lecturer Student each lecturer tutors a group of students Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Tutors Student Entity Relationship (ER) Model

Entity Relationship (ER) Model Example - E/R Diagram Draw an ERD for a small college database comprising the entity types: DEPARTMENT, COURSE, STUDENT and LECTURER.  Each department has many lecturers, one of whom is the head of department. A lecturer belongs to only one department. Each department offers many different courses, and many lecturers can teach on a single course. Lecturers can also teach on more than one course. A student may enrol for many courses offered by different departments. Entity Relationship (ER) Model

Symbols Used in E-R Notation-summary The attributes are connected using lines to the entities. If the attribute is simple or single valued a single line is used If the attributes is derived a dotted line is used If it is multi-valued then double line are used If the attribute is composite, its component attributes are shown as ellipse emanating from the composite attribute Entity Relationship (ER) Model

Symbols Used in E-R Notation(cont.) Entity Relationship (ER) Model

Alternative E-R Notations Entity Relationship (ER) Model