Download presentation
Presentation is loading. Please wait.
Published byGyles Hawkins Modified over 9 years ago
1
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Data Modeling Using the Entity- Relationship (ER) Model Hour1 Presented & Modified by Mahmoud Rafeek Alfarra Lecturer in CST Kan younis
2
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Chapter 4 Outline Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys Relationship Types, Relationship Sets, Roles, and Structural Constraints Weak Entity Types
3
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Chapter 4 Outline (cont’d.) Refining the ER Design for the COMPANY Database ER Diagrams, Naming Conventions, and Design Issues Example of Other Notation: UML Class Diagrams Relationship Types of Degree Higher than Two
4
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Entity-Relationship (ER) Model Entity-Relationship (ER) model Popular high-level conceptual data model ER diagrams Diagrammatic notation associated with the ER model Unified Modeling Language (UML)
5
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Using High-Level Conceptual Data Models for Database Design Requirements collection and analysis Database designers interview prospective database users to understand and document data requirements Result: data requirements Functional requirements of the application
6
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Entity Types, Entity Sets, Attributes ER model describes data as: Entities Relationships Attributes
7
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Entities and Attributes Entity Thing in real world with independent existence Attributes Particular properties that describe entity Types of attributes: Composite versus simple (atomic) attributes Single-valued versus multivalued attributes Stored versus derived attributes NULL values Complex attributes
8
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 ER Diagrams, Naming Conventions, and Design Issues
9
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Types of attributes A composite attribute An attribute broken into component parts
10
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Types of attributes Simple key attribute The key is underlined
11
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Types of attributes Composite key attribute The key is composed of two subparts
12
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Types of attributes multivalued derived Entity with a multivalued attribute (Skill) and derived attribute (Years_Employed) Derived from date employed and current date Multivalued: an employee can have more than one skill
13
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Types of attributes An attribute that is both multivalued and composite This is an example of time-stamping
14
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Entities and Attributes
15
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 و ذكـِّر عَنْ أَبِي الدَّرْدَاءِ رضي الله عنه، قَالَ : " إِنَّمَا الْعِلْمُ بِالتَّعَلُّمِ ، وَإِنَّمَا الْحِلْمُ بِالتَّحَلُّمِ ، وَمَنْ يَتَوَخَّ الْخَيْرَ يُعْطَهُ ، وَمَنْ يَتَوَقَّ الشَّرَّ يُوقَهُ ". موقوف
16
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Data Modeling Using the Entity- Relationship (ER) Model Hour2 Presented & Modified by Mahmoud Rafeek Alfarra Lecturer in CST Kan younis
17
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Entity Types, Entity Sets and Value Sets Entity type Collection (or set) of entities that have the same attributes (often corresponds to a table)
18
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Initial Conceptual Design of the COMPANY Database
19
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Initial Conceptual Design of the COMPANY Database
20
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Relationship Types, Relationship Sets, Roles, and Structural Constraints Relationship When an attribute of one entity type refers to another entity type Represent references as relationships not attributes
21
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Relationship Types, Sets, and Instances The relationship type is modeled as the diamond and lines between entity type. The instance is between specific entity instances.
22
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Relationship Degree Degree of a relationship type Number of participating entity types Unary, Binary, ternary Relationships as attributes Think of a binary relationship type in terms of attributes
23
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Relationship Degree One entity related to another of the same entity type Entities of two different types related to each other Entities of three different types related to each other
24
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Ternary
25
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011
26
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 و ذكـِّر عن أبي عبد الرحمن معاذ بِن جبل رضي الله عنهما : عن رسول الله صلى الله عليه وسلم قال : ( اتق الله حيثما كنت، وأتبع السيئة الحسنة تمحها ، وخالق الناس بخلق حسن ). حديث حسن.
27
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Data Modeling Using the Entity- Relationship (ER) Model Hour3 Presented & Modified by Mahmoud Rafeek Alfarra Lecturer in CST Kan younis
28
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships One-to-One 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
29
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity. Minimum Cardinality If zero, then optional. If one or more, then mandatory. Maximum Cardinality The maximum number.
30
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships
31
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships
32
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Note: a relationship can have attributes of its own
33
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Basic relationship with only maximum cardinalities showing
34
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Mandatory minimum cardinalities
35
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships
36
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Here, the date completed attribute pertains specifically to the employee’s completion of a course…it is an attribute of the relationship A binary relationship with an attribute
37
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships A unary relationship with an attribute. This has a many- to-many relationship
38
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Cardinality of Relationships Entities can be related to one another in more than one way
39
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Weak Entity Types Do not have key attributes of their own Identified by being related to specific entities from another entity type Identifying relationship Relates a weak entity type to its owner Always has a total participation constraint
40
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Refining the ER Design for the COMPANY Database Change attributes that represent relationships into relationship types Determine cardinality ratio and participation constraint of each relationship type
41
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 A Sample Database Application COMPANY Employees, departments, and projects Company is organized into departments Department controls a number of projects Employee: store each employee’s name, Social Security number, address, salary, gender, and birth date Keep track of the dependents of each employee
42
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
44
modified by Mahmoud Rafeek Alfarra, April 2011 Example of Other Notation: UML Class Diagrams UML methodology Used extensively in software design Many types of diagrams for various software design purposes UML class diagrams Entity in ER corresponds to an object in UML Case Study Next Sunday 17 April
45
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
46
modified by Mahmoud Rafeek Alfarra, April 2011 Example of Other Notation: UML Class Diagrams Class includes three sections: Top section gives the class name Middle section includes the attributes; Last section includes operations that can be applied to individual objects
47
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Example of Other Notation: UML Class Diagrams Associations: relationship types Relationship instances: links Binary association Represented as a line connecting participating classes May optionally have a name Link attribute Placed in a box connected to the association’s line by a dashed line
48
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Example of Other Notation: UML Class Diagrams Multiplicities: min..max, asterisk (*) indicates no maximum limit on participation Types of relationships: association and aggregation Distinguish between unidirectional and bidirectional associations Model weak entities using qualified association
49
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 Summary Basic ER model concepts of entities and their attributes Different types of attributes Structural constraints on relationships ER diagrams represent E-R schemas UML class diagrams relate to ER modeling concepts
50
Copyright © 2011 Ramez Elmasri and Shamkant Navathe modified by Mahmoud Rafeek Alfarra, April 2011 و ذكـِّر قال الله تعالى: ( وَلَقَدْ وَصَّيْنَا الَّذِينَ أُوتُوا الْكِتَابَ مِنْ قَبْلِكُمْ وَإِيَّاكُمْ أَنِ اتَّقُوا اللَّهَ ) ( النساء : من الآية 131)
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.