ITS232 Introduction To Database Management Systems 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 (ERD)
64
Embed
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ITS232Introduction To Database Management Systems
Siti Nurbaya IsmailFaculty of Computer Science & Mathematics,
Universiti Teknologi MARA (UiTM), Kedah| [email protected] | http://www.sitinur151.wordpress.com |
| A2-3039 | ext:2561 | 012-7760562 |
CHAPTER 4Entity Relationship (E-R) Modeling
(ERD)
4.0 Entity Relationship (E-R) Modeling4.1 The Entity Relationship (ER) Model 4.2 Developing An E-R Diagram 4.3 Database Design Challenges
Chapter 4: Entity Relationship (E-R) Modeling4.1 The Entity Relationship (E-R) Model
7
Based on the set theory and the relational theory, it is used as tools to:– translate different views of data among managers, 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 * relationship
Chapter 4: Entity Relationship (E-R) Modeling4.1 The Entity Relationship (E-R) Model
8
• 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:
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
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
Chapter 4: Entity Relationship (E-R) Modeling4.1 The Entity Relationship (E-R) Model
11
The Attributes of the STUDENT entity: Chen & Crow’s Foot
RELATIONSHIP Relationship can be describes by:i. Degree of the relationshipii. Connectivity of the relationshipiii. Cardinality of the relationshipiv. Participation
Entity• Corresponds to table and not to row in relational environment• Represented by rectangle containing entity’s name• Entity name, a noun, is usually written in capital letters• Examlpe: Entity STUDENT with 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
contactid firstname lastname hobbies1639 George Barnes reading5629 Susan Noble hiking, movies3388 Erwin Star hockey, skiing5772 Alice Buck1911 Frank Borders photography, travel, art4848 Hanna Diedrich cooking, movies
• An attributes that represents a value that is derived from the value of related attribute or set of attributes, not necessarily in the same entity type.
• Need not be physically stored within database• Example: age
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
Unary Relationship Type R, we identify the relation A represents the entity type involves in this relationship. Include in this relation one more time as foreign key the primary of itself. The two keys (primary key and foreign key) are the same but they represents two entities of different roles relate to this relationship.
1-1 Binary Relationship Type 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.
Choose one of the participating relation, say A (usually one with total participation) ; include in A as the foreign key the primary key of B. If R has attributes then put them in the relation A as well.
• 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.
• Defining relationship relation: Define a relation R to represent the relationship. All attributes of relationship is included in R. In addition, put the primary keys of two relations A , B into R. The primary keys of R is combination of primary keys of A and B.
1-N Binary Relationship Type: For each 1-N Binary Relationship Type R, identify two relations A and B correspond to two entity types participating in R. A represents the entity type at 1-side and B represents the entity type at N-side. Include the primary key of A as the foreign key in B. This foreign key represent the relationship type R.
M-N Binary Relationship Type: For each M-N Binary Relationship Type R, identify two relation A, B represent two entity type participating in R. Create a new relation S to represent R. Include in S as foreign keys the primary keys of A and B and all the simple attributes of R. The combination of primary keys of A and B will make the primary key of S.
Ternary Relationship Type: For each n-ary ( > 2 ) Relationships create a new relation to represent the relationship. The primary key of the new relation is the combination of the primary keys of the participating entities that hold the N (many) side. In most cases of an n-ary relationship all the participating entities hold a many side