Download presentation
Presentation is loading. Please wait.
Published byEugene Dorsey Modified over 9 years ago
1
Entity-Relationship Model Chapter 3 II COSC 457 Sungchul Hong
2
COMPANY Database DEPARTMENT –Name, Number, {Locations}, Manager, ManagerStartDate PROJECT –Name, Number, Location, ControllingDepartment EMPLOYEE –Name (FName, MInit, LName), SSN, Sex, Address, Salary, BirthDate, Department, Supervisor, {WorksOn(Project, Hours)} DEPENDENT –Employee, DependentName, Sex, BirthDate, Relationship
4
Relationship, Relationship Types, and Structural Constraints In the initial design of entity types, relationships are typically captured in the from of attributes. The attribute Manager of DEPARTMENT refers to an employee who manages the department.
5
Relationship Types, Set and Instances A relationship type R among n entity types E 1, E 2, …, E n defines a set of associations or a relationship set among entities from these types. The relationship set R is a set of relationship instances r i, where each r i associates n individual entities (e 1, e 2, …, e n ), and each entity e j in r i is a member of entity type E j, 1 j n. A relationship type is a mathematical relation on E 1, E 2, …, E n, or alternatively it can be defined as a subset of the Cartesian product E 1 E 2 …E n. Relationship instance r i =(e 1,e 2, …, e n )
7
Mathematical Relations Sets D 1 and D 2 where D 1 = {2, 4} and D 2 ={1, 3, 5}. Cartesian product D 1 D 2, is the set of all ordered pairs such that the first element is a member of D 1 and the second element is a member of D 2. –D 1 D 2 ={(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}
8
Example The company is organized into departments. Each department has a unique name, a unique number, and a particular employee who manages the department. We keep track of the start date when that employee began managing the department. A department may have several locations.
9
Example (2) A department controls a number of projects, each of which has a unique name, a unique number, and single location. We store each employee’s name, social security number, address, salary, sex, and birth date. An employee is assigned to one department but may work on several projects, which are not necessarily controlled by the same department. We keep track of the number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee.
10
User Requirement Example (3) We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first name, sex, birth date, and relationship to the employee.
12
Relationship Degree, Role Names, and Recursive Relationship Degree of a Relationship Type –The number of participating entity types. Binary, ternary, quaternary, and etc. –E.g. WORKS_FOR has degree 2 or binary Relationships as Attributes –Attribute Department of the EMPLOYEE entity Role Names and Recursive Relationships –The role name signifies the role that a participating entity from the entity type plays in each relationship instance.
13
Binary Relationship Employee Project Works_on
14
SupplierProject Part Supply
15
Employee Supervise
16
Constraints on Relationship Types Cardinality Ratios for Binary Relationships –1:1 (MANAGES EMPLOYEE : DEPARTMENT) –1:N (WORK_FOR DEPARTMENT : EMPLOYEE) –M:N (WORKS_ON EMPLOYEE : PROJECT) Participation Constraints and Existence Dependences (structural constraints) –Total participation (Double lines) –Partial dependences
17
Attributes of Relationship Types 1:1 1:N N:M –Some attributes may be determined by the combination of participating entities in a relationship. –Attributes must be specified as relationship attributes
18
1 1 1 1 0 1 1 0 0 0 Min: Max:
19
1 1 1 1 1 1 1 3 2 2 Min: Max: Min: Max:
20
1 2 3 1 2 1 2 2 Min: Max: Min: Max:
21
The (min,max) notation relationship constraints (0,1) (1,1) (1,N) (1,M) (1,N)
22
Weak Entity Types Entity types that do not have key attributes of their own. The relationship type that relates a weak entity type to its owner is called the identifying relationship of the weak entity type. Partial key: the set of attributes that can uniquely identify weak entities that are related to the same owner entity. Example: Employee{SSN, LName, FName} Dependant{FName, DOB}
23
Example Relationships MANAGES WORKS_FOR CONTROLS SUPERVISION WORKS_ON DEPENDENTS_OF
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.