Download presentation
Presentation is loading. Please wait.
Published byEmil Tyler Modified over 9 years ago
1
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Continued)
2
Database Management COP4540, SCS, FIU Entity-Relationship Review Entities –Entity class vs. Entity instance Attributes –Single attribute vs. Multivalued attribute –Simple attribute vs. Composite attribute –Stored attribute vs. Derived attribute Relationships –Degree –Cardinality
3
Database Management COP4540, SCS, FIU An Example Database Application The company is organized into departments. Each departments 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. A department controls a number of projects, each of which has a unique name, a unique number, and a single location. We store each employee’s name, SSN, address, salary, sex, birth date, and age. 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. Each employee may have only one direct supervisor.
4
Database Management COP4540, SCS, FIU Database Design Steps (1) The Entity class DEPARTMENT and its properties DEPARTMENT name number locations manager projects Problems: How to express the start date of a manager? How to express the properties of a project?
5
Database Management COP4540, SCS, FIU Database Design Steps (2) The Entity class PROJECT and its properties PROJECT name number locations Problem: How to relate PORJECT and DEPARTMENT
6
Database Management COP4540, SCS, FIU Database Design Steps (3) The relationship between DEPARTMENT and PROJECT DEPARTMENT name number locations manager PROJECT name number locations Controls 1 N
7
Database Management COP4540, SCS, FIU Database Design Steps (4) The Entity class EMPLOYEE and its properties EMPLOYEE name firstnamelastname middle SSNaddress street city state zip birthdate age dept_name projectssupervisor Question: An entity or an attribute? salary
8
Database Management COP4540, SCS, FIU Database Design Steps (5) The Refinement of the Entity class EMPLOYEE EMPLOYEE supervision 1 N supervisorsupervisee DEPARTMENT Works_for 1 N PROJECT Works_on M N hours
9
Database Management COP4540, SCS, FIU Another relationship between EMPLOYEE and DEPARTMENT Database Design Steps (6) EMPLOYEE supervision 1 N supervisorsupervisee DEPARTMENT Works_for 1 N PROJECT Works_on M N hours Manages 1 1
10
Database Management COP4540, SCS, FIU EMPLOYEE supervision 1 N supervisorsupervisee DEPARTMENT Works_for 1N PROJECT Works_on M N hours Manages 1 1 name number locations Controls 1 N name number locations name firstname lastname middle street city state zipaddress birthdate age SSNsalary Final Design
11
Database Management COP4540, SCS, FIU Weak Entities Do not have key attributes of their own. Each has a dependent entity namely identifying owner Identifying relationship links itself and the owner. Weak entity identifier is its partial identifier combined with that of its owner. Donations –Double lined rectangular box. –Double lined diamond shape box.
12
Database Management COP4540, SCS, FIU Weak Entity (2) Key attributes come not (completely) from its own attributes, but from the keys from some other entity sets’. It is Represented by putting double rectangle around, and a double diamond around each relationship to which the weak E.S. is linked to an E.S. that provides part of its key. Use of many-one relationship (includes 1-1) essential.
13
Database Management COP4540, SCS, FIU Weak Entity Example Logins (Email Addresses) Login name = user name + host name, e.g., yuanj@solix.fiu.edu. login entity corresponds to a user name on a particular host, but the password table doesn't record the host, just the user name, e.g. yuanj. Key for a login = the user name at the host (which is unique for that host only) + the IP address of the host, which is unique globally.
14
Database Management COP4540, SCS, FIU user_name password HOST IP address At LOGIN N1 Example E-R Diagram
15
Database Management COP4540, SCS, FIU An Example Database Application The company is organized into departments. Each departments 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. A department controls a number of projects, each of which has a unique name, a unique number, and a single location. We store each employee’s name, SSN, address, salary, sex, birth date, and age. 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. Each employee may have only one direct supervisor. We want to keep track of the dependents of each employee for insurance purpose. We keep each dependent’s first name, sex, birth date and relationship to employee.
16
Database Management COP4540, SCS, FIU The Weak Entity DEPENDENT DEPENDENT namesex birthdate relationship EMPLOYEE Dependents_of 1 N SSN
17
Database Management COP4540, SCS, FIU EMPLOYEE supervision 1 N supervisorsupervisee DEPARTMENT Works_for 1N PROJECT Works_on M N hours Manages 1 1 name number locations Controls 1 N name number locations name firstname lastname middle street city state zipaddress birthdate age SSNsalary DEPENDENT name sex birthdate relationship Dependents_of 1 N
18
Database Management COP4540, SCS, FIU Example: Chain of “Weakness” Consider IP addresses consisting of a primary domain (e.g., edu) subdomain (e.g., fiu), and host (e.g. solix). –Key for primary domain = its name. –Key for secondary domain = its name + name of primary domain. –Key for host = its name + key of secondary domain = its name + name of secondary domain + name of primary domain.
19
Database Management COP4540, SCS, FIU Example E-R Diagram HOST DOMAIN name In SUB-DOMAIN In N 1 N 1 WWW WWW WWW EDU COM FIU MIT ORACLE
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.