Entity Relationship e r Modeling Mine Ee (1)

March 17, 2018 | Author: Izza Nasir | Category: Conceptual Model, Relational Database, Computer Data, Data Management, Scientific Modeling


Comments



Description

ITS232Introduction To Database Management Systems CHAPTER 4 Entity Relationship (E-R) Modeling (ERD) Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah | [email protected] | http://www.sitinur151.wordpress.com | | A2-3039 | ext:2561 | 012-7760562 | Chapter 4: Entity Relationship (E-R) Modeling 4.0 Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (ER) Model 4.2 Developing An E-R Diagram 4.3 Database Design Challenges Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept A model is description or analogy used to visualize something that cannot be directly observed. 3 which the database to be develop. student = physical – subject. 4 .Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept • Relatively simple representations of complex real world data structures • A data model represents: – data structures and their characteristics – relation and constraints • Can be physical or abstract: – car. register= abstract • Used by database designer as: – communications tools to communicate and understanding between a client and the database designer. Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept The importance of data modeling: • Data – constitute the most basic information units employed by a system • Application – is created to manage data and to transform data to information • View – different people views the same data differently based on their understanding • Model – helps different user to have the holistic view of the same data 5 . External level User n … Model 2.Internal Internal level Model -DBMS’s view -h/w independent -s/w dependent Internal Schema Physical data Physical Model organization -h/w dependent -s/w dependent View n ERD Database 6 .Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept Three Level ANSI-SPARC Architecture User 1 User 2 View 1 View 2 -user’s view External Model 1.Conceptual Conceptual level -designer’s view -h/w independent -s/w independent Conceptual Schema 3. it is used as tools to: – translate different views of data among managers.Chapter 4: Entity Relationship (E-R) Modeling 4. users and programmers to fit into a common work – define data processing and constraints to help meet the different views – help implement the database – considered as a stage in a database design preceding/before the relational database modeling – gives data structures representation of: * what information to be stored * the relationships between informational elements and constraint on the data structure 7 * relationship .1 The Entity Relationship (E-R) Model Based on the set theory and the relational theory. Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model • ER model forms the basis of an ER diagram (ERD) • ERD represents conceptual database as viewed by end user • ERDs depict/shows database’s main components: – Entities – Attributes – Relationships 8 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model: Entity Entity • Represents an object from the real world • Collection of similar entities that made up entity sets • Refers to entity set and not to single entity occurrence • Corresponds to table and not to row in relational environment • In both Chen and Crow’s Foot models, entity is represented by rectangle containing entity’s name • Entity name, a noun, is usually written in capital letters 9 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model: Attribute Attribute • Characteristics of entities • Property that explains about entity • Correspondents to fields of a table • Primary key are underline with a straight line • Foreign key are underline with dotted line or an * • Chen Model • attributes are represented by ovals and are connected to entity rectangle with a line • each oval contains the name of attribute it represents • Crow’s Foot Model • attributes are written in attribute box below entity rectangle 10 1 The Entity Relationship (E-R) Model The Attributes of the STUDENT entity: Chen & Crow’s Foot 11 .Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model: Relationship Relationship • Associates between entities/connection between two or more entities • Logical interaction among the entities in a relational database • Operate in both directions • Chen Model • Crow’s Foot Model 12 . Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram Development of ER model is an Iterative Process that involved: • Step1: General narrative of organizational operations developed • Step2: Basic E-R Model graphically depicted and reviewed • Step3: Modifications made to incorporate newly discovered ER components • Repeat process: Until designers and users agree on complete E-R Diagram 13 . Derived attributes RELATIONSHI Relationship can be describes by: P i. Composite iv. Degree of the relationship ii. Recursive iii.Chapter 4: Entity Relationship (E-R) Modeling 4. Participation 14 . Cardinality of the relationship iv. Connectivity of the relationship iii.2 Developing An E-R Diagram: Model Components ENTITY Variations of entity: i. Composite attributes iii. Weak ii. Supertype/Subtype ATTRIBUTE Types of attribute: i. Multivalued attributes iv. Simple attributes ii. 2 Developing An E-R Diagram: Chen Model: Entity Entity • Corresponds to table and not to row in relational environment • Represented by rectangle containing entity’s name • Entity name. a noun.Chapter 4: Entity Relationship (E-R) Modeling 4. is usually written in capital letters • Examlpe: Entity STUDENT with attributes 15 . Weak Entity ii.Chapter 4: Entity Relationship (E-R) Modeling 4. Recursive Entity iii.2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: i. Entity Supertype and Subtype 16 . Composite Entity iv. Existence-dependent • Entity B depends on Entity A to exist. If A does not exist then B cannot exist too –. Weak Entity –. Primary key partially or totally derived from parent entity in relationship –. Database designer determines whether an entity is weak based on business rules 17 .Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: i. 2 Developing An E-R Diagram: Chen Model: Entity 18 .Chapter 4: Entity Relationship (E-R) Modeling 4. 2 Developing An E-R Diagram: Chen Model: Entity 19 .Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4. Recursive Entity • Entity set that have relationship with the same entity set • Example: EMPLOYEE entity employeeMANAGER employeeSPOUSE employeeNAME employeeNO employeeNAME employeeNO 1 EMPLOYEE 1 1 married Ah Chong 333 Bazil 444 Sheriz 1 manage employeeNO employeeNAME employeeSPOUSE 111 Ali 444 222 EMPLOYEE 111 employeeNO 111 222 333 employeeNAME Ali Ah Chong Bazil 444 Sheriz employeeMANAGER 333 333 333 20 .2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: ii. 2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iii. Composite Entity • Originally a relationship between 2 entities that involved in M:N relationship • Composite entity takes its primary key from both entities that it bridges • Example: enroll grade studentNAME studentID STUDENT studentID 200922222 200933333 200944444 STUDENT studentNAME M courseNAME N enroll STUDENT_COURSE / ENROLL studentID 200922222 200922222 200933333 200955555 courseID ITS232 CSC318 CSC203 ITS232 grade A+ B+ B A- courseID COURSE COURSE courseID courseNAME ITS232 Database CSC318 IP CSC203 OS .Chapter 4: Entity Relationship (E-R) Modeling 4. Entity Supertype & Subtype • Parent-Child relationship • Supertypecontains the shared attributes an entity type that include distinct subclasses that required to be presented in data model parent • Subtype contains the unique attributes an entity type that has a distinct role and also a member of supertype child 22 .2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv.Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4. Example: Superype (EMPLOYEE) Subtype (Engineer & Full-Time) 23 .2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv. Entity Supertype & Subtype •. Entity Supertype & Subtype • Have two types of relationship: Disjoint Overlapping Unique subtype Non-overlapping: subtypes can be one of the types Indicate with: G Overlapping: Subtypes can be either one or both of the subtypes Indicate with: Gs 24 .2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv.Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4. Example: Disjoint & Overlap Disjoint G Gs Overlap 25 . Entity Supertype & Subtype •.2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv. Example: Disjoint 26 . Entity Supertype & Subtype •. 2 Developing An E-R Diagram: Chen Model: Entity Variations of Entity: iv. Example: Disjoint & Overlap 27 .Chapter 4: Entity Relationship (E-R) Modeling 4. Entity Supertype & Subtype •. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Attributes Attributes • Represented by ovals that are connected to entity with a line • Oval contains of attribute (field) it represents • PK are underlined with straight line • FK are underlined with doted line or * • Example: Entity STUDENT with attributes name. email name email address STUDENT course studentID 28 . course. address. studentID. Multivalued Attributes iv.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: i. Composite Attributes iii. Simple Attributes ii. Derived Attributes 29 .Chapter 4: Entity Relationship (E-R) Modeling 4. martial statues addressNO address addressPOSTCODE addressTOWN Simple Attributes phoneNO age STUDENT name gender studentID 30 . Simple Attributes • An attribute composed of single component with an independent existence • Cannot be subdivided into smaller components • Example: gender.Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: i. zip addressNO address phoneNO age STUDENT name gender addressPOSTCODE addressTOWN Composite Attributes studentID 31 .Chapter 4: Entity Relationship (E-R) Modeling 4. state.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: ii. last address street. Composite Attributes • An attribute composed of multiple components. city. each with an independent existence • Can be further subdivide to additional attributes • Example: name  first. middle. master 32 .office. Create new entity of the original multivalued attributes components • Example: phone number handset.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: iii.home qualification diploma. Multivalued Attributes • attribute that holds multiple values for each occurrence of an entity type • Should not be implemented multivalued attributes in relational database • Can simplifies multivalued attributes by: a. Create several attributes b.Chapter 4: Entity Relationship (E-R) Modeling 4.degree. art 4848 Hanna Diedrich cooking.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: iii. skiing 5772 Alice Buck 1911 Frank Borders photography. movies 3388 Erwin Star hockey. movies 33 . travel.Chapter 4: Entity Relationship (E-R) Modeling 4. Multivalued Attributes Contact hobbies contac firstna tid me lastnam e hobbies 1639 George Barnes reading 5629 Susan Noble hiking. 2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: iii. 0355446712 1911 F 18 Besut 0199556301. 095723992 age address contactnum 34 . 0333721341 5629 M 18 Temerloh 0199871234. 4848 F 18 Machang 0144543331. 094602721 3388 M 19 Jerantut 0199112344. Multivalued Attributes Contact hobbies studenti d gend er 1639 M 18 Klang 0123456734.Chapter 4: Entity Relationship (E-R) Modeling 4. 094601234 5772 F 18 Hulu Klang 0193448900. 094602721. Multivalued Attributes • Can simplifies multivalued attributes by: a.2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: iii.Chapter 4: Entity Relationship (E-R) Modeling 4. Create new entity of the original multivalued handsetNO homephoneNO attributes address components age gender STUDENT studentID has CONTACT studentID* 35 . Create several attributes address age gender STUDENT studentID handsetNO homephoneNO b. 2 Developing An E-R Diagram: Chen Model: Attributes Attributes types: iv. • Need not be physically stored within database • Example: age 36 . Derived Attributes • An attributes that represents a value that is derived from the value of related attribute or set of attributes.Chapter 4: Entity Relationship (E-R) Modeling 4. not necessarily in the same entity type. 2 Developing An E-R Diagram: Chen Model: Attributes 37 .Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Relationship • Associations /connection between entities • Logical interaction among the entities in a relational database • Operates in both directions • Naming Relationships: • Relationship name is a verb phrase • Avoid vague names • Defining Relationships: • • • • • • • Definition explains what action is being taken and why it is important Give examples to clarify the action Optional participation should be explained Explain reasons for any explicit maximum cardinality Explain any restrictions on participation in the relationship Explain extent of the history that is kept in the relationship Explain whether an entity instance involved in a relationship instance can transfer participation to another relationship instance 38 . Degree of the relationship ii. Cardinality of the relationship iv.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: i. Participation 39 .Chapter 4: Entity Relationship (E-R) Modeling 4. Connectivity of the relationship iii. Two entities are associated (1:1.Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: i. Degree of the relationship • Indicates number of associated entities within the relationship • There are three types: a.Three entities are associated 40 . 1:M.Binary Relationship •. M:N) c. Ternary Relationship •.Unary Relationship • Association is maintained within single entity b. 2 Developing An E-R Diagram: Chen Model: Relationship 41 .Chapter 4: Entity Relationship (E-R) Modeling 4. The two keys (primary key and foreign key) are the same but they represents two entities of different roles relate to this relationship. we identify the relation A represents the entity type involves in this relationship.Chapter 4: Entity Relationship (E-R) Modeling 4. Include in this relation one more time as foreign key the primary of itself.2 Developing An E-R Diagram: Chen Model: Relationship PK A PK FK FK EID Name 111 Ikhsan 222 Eizan 333 Nawal Super_ EID 111 444 Fairuz 222 Unary Relationship Type R. 42 . In addition. B into R. 43 . put the primary keys of two relations A .2 Developing An E-R Diagram: Chen Model: Relationship A B A B R 1-1 Binary Relationship Type R. If R has attributes then put them in the relation A as well. include in A as the foreign key the primary key of B. • Defining relationship relation: Define a relation R to represent the relationship. The primary keys of R is combination of primary keys of A and B. say A (usually one with total participation) . All attributes of relationship is included in R. identify relation A and B that correspond to the entity types participating in R. The relationship itself can be mapped using one of the following approaches: • Using foreign key: This is the most popular approach.Chapter 4: Entity Relationship (E-R) Modeling 4. Choose one of the participating relation. • Merged relation: If both participations of two related entity type are total then we can merge two entity types and the relationship into a relation. Include the primary key of A as the foreign key in B.2 Developing An E-R Diagram: Chen Model: Relationship A B 1-N Binary Relationship Type: For each 1-N Binary Relationship Type R.Chapter 4: Entity Relationship (E-R) Modeling 4. 44 . A represents the entity type at 1-side and B represents the entity type at N-side. identify two relations A and B correspond to two entity types participating in R. This foreign key represent the relationship type R. Chapter 4: Entity Relationship (E-R) Modeling 4. 45 . The combination of primary keys of A and B will make the primary key of S.2 Developing An E-R Diagram: Chen Model: Relationship A B S M-N Binary Relationship Type: For each M-N Binary Relationship Type R. identify two relation A. Include in S as foreign keys the primary keys of A and B and all the simple attributes of R. B represent two entity type participating in R. Create a new relation S to represent R. In most cases of an n-ary relationship all the participating entities hold a many side 46 . The primary key of the new relation is the combination of the primary keys of the participating entities that hold the N (many) side.Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Ternary Relationship Type: For each n-ary ( > 2 ) Relationships create a new relation to represent the relationship. Chapter 4: Entity Relationship (E-R) Modeling 4.1:1 1 1 have RECTOR UiTMBRANCH b. Connectivity of the relationship • Logical interaction among entities in a relational database • There are three types: a.M:N STUDENT 1 1 M under M PROGRAM register N COURSE 47 .1:M STUDENT c.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: ii. Cardinality of the relationship • Express the specific (minimum and maximum) number of entity occurrences associated with one occurrence of the related entity • Function of organizational policy  business rules 48 .Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii. 9) N register (0.Chapter 4: Entity Relationship (E-R) Modeling 4. Cardinality of the relationship • Example 1: One student can register 1 to 9 courses One course maximum can have 35 student STUDENT M (1.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii.35) COURSE 49 . Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii. Cardinality of the relationship • Example 2: One lecturer can teaches maximum 3 courses One course can be thought by 1 lecturer only LECTURER 1 (0.1) COURSE 50 .3) M teach (1. 2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii.Chapter 4: Entity Relationship (E-R) Modeling 4. Cardinality of the relationship • Example 3: 51 . Existence independence • Entity can exist apart from one or more related entities • Sometimes such an entity is referred to as a strong or regular entity .2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii. Cardinality of the relationship • Relationship Strength  Existence Dependence –.Chapter 4: Entity Relationship (E-R) Modeling 4. Existence dependence • Entity exists in database only when it is associated with another related entity occurrence –. exist two relationship strength: a. Cardinality of the relationship • From Existence Dependence.Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iii.Weak Relationship  Entity not existence-independent on other entity  PK of related entity doesn’t contain PK component of parent entity  Non-Identifying Relationship b.Strong Relationship  Existence dependence  PK of related entity contains PK component of parent entity  Identifying Relationship 53 . 54 . 55 . 9h Edition 56 .Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship Database Systems. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship 57 . One entity occurrence requires corresponding entity occurrence in particular relationship 58 .Optional (Partial) •. One entity occurrence does not require corresponding entity occurrence in particular relationship b.2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iv. Participation • Determines whether all or some entity occurrences participates in a relationship • There are two types: a.Chapter 4: Entity Relationship (E-R) Modeling 4.Mandatory (Total) •. 3) M teach ‘not all lecturer teaches course’ One lecturer can teaches maximum 3 courses optional participation for course (1.Chapter 4: Entity Relationship (E-R) Modeling 4. Participation • Example 1: One lecturer can teaches maximum 3 courses One course can be thought by 1 lecturer only connectivity LECTURER 1 (0.1) COURSE One course can be thought by one lecturer only cardinality participation ‘all courses are taught’ (mandatory participation for lecturer) .2 Developing An E-R Diagram: Chen Model: Relationship Relationship is described by: iv. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of E-R Model Alternate style developed to enable easier use of CASE tools. Chen Model The Chen notation favors conceptual modeling Crow’s Foot Model Crow’s Foot notation favors a more implementationoriented approach UML Model UML notation can be used for both conceptual and implementation modeling 60 . 2 Developing An E-R Diagram: Comparison of Comparison of E-R Modeling Symbols E-R Model Cardinality & Participation Chen Model Entity Weak Entity Composite Entity Relationship line Relationship Option Symbol One (1) Symbol 1 Many (M) Symbol M Crow’s Foot Model .Chapter 4: Entity Relationship (E-R) Modeling 4. Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of Chen Model E-R Model . Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of Crow’s Foot Model E-R Model . Chapter 4: Entity Relationship (E-R) Modeling 4. • In order to do so.3 Database Design Challenges Conflicting Goals • Database designers often must make design compromises that are trigged by conflicting goals. – it is very important to have the entities. and relationships clearly identified and well-defined – there is a need in balancing between the customer needs and a design that meets logical requirements and conventions – The more thinking and modeling is done the less money and time are needed later on for rework 64 . processing speed and information requirements. such as comply with the design standards. attributes.
Copyright © 2024 DOKUMEN.SITE Inc.