Practice of ER Modeling: Yong Choi School of Business Csub

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

Practice of ER modeling

Yong Choi
School of Business
CSUB
Practice 1
 A department hires many employees. A
employee is hired by one department.
 Dept (one) ------------ Employee (many)

 A manager manages one department. A


department is managed by one manager.
 Manager (one) ------------ Dept (one)
Practice 2
 An author may write many books. A book may
be written by many authors.
 Author (many, optional) ------------ Book (many,
optional)

 A team consists of many players. A player


plays for only one team.
 Team (one) ------------ Player (many)
Practice 3
 A lecturer teaches, at most, one course. A
course is taught by exactly one lecturer.
 Lecturer (one) -------- course (one)

 A flight-hub connects two airports. An airport


is used by many flight-hubs.
 Flight-leg (many) -------------- Airport (many)
Practice 4
 A purchase order may be for many products.
A product may appear on many purchase
orders.
 Purchase Order (many, optional) --------------
Product (many, optional)

 A customer may submit many orders. An


order is for exactly one customer.
 Customer (one) -------------- Order (many, optional)
Practice 5
 A college has a large number of professors.
Each professor may belong to one or several
colleges in one university. In some cases, a
professor may not belong to any college at
all.
 As a beginner, refine the paragraph……easier
 College (many, optimal) ------- Professor (many)
Practice 6
 The California State University has changed one of
the policies about course schedule based upon
feedback from professors and students. One of the
changed policies is that a course may have one or
more scheduled sections, or may not have a
scheduled section. Each section has one course or
may not have any course at all.
 An entity without relationship description and
cardinality description may not be a candidate.
 Take away unnecessary information….
 Course (one, optimal) ------ Section (many, optional)
Practice 7
 According to the policy of the California
Hospital, a patient must have a patient
record. In other words, each patient may
have one or more records. Each patient
record must belong to exactly one patient.

 Patient (one) ------ Patient Record (many, optional)


Practice 8
 Since the growth rate of the California video store is
very fast, the store has decided to change the
inventory management policy. One of the policy is
that a video store may stock more than one copy of a
given movie and only one copy of a given movie can
belong to one video store.

 Entity naming!
 Video store (optional) --- Video Tape (many, optional)
Practice 9 – Multiple Entities
 A college runs many classes. Each class may be
taught by several professors. A particular class may
always uses the same room. Because classes may
held at different times or on different evenings, it is
possible that each room is used by many different
classes. By the way, A professor can teach several
classes.
 Professor (many, optional) ---- class (many, optional)
 Class (many, optional) ---- room (one, optional)
Practice 10 – Multiple Entities
 There are several departments in School of Business
and Public Administration at CSUB (indication that
cardinality from school to Dept is many). Each
department belongs to one school. A department has
many professors, but a professor may belong to more
than one department. Similarly, courses may be
offered by several departments and a department
must have at least one course. A professor may
teach more than one student, and a student may
have more than one professor.
Practice 10 - answer
Course

School Department

Student Professor
Practice 11 – Multiple Entities
 Each employee in an engineering company has one
recognized skill (e.g., mechanic, electrician), but a
given skill may be possessed by several employees.
An employee must be able to operate a given
machine-type (e.g., milling machine, grinder). If any
employee has one of several skills, each skill must be
associated with the operation of only one machine
type. Possession of a given skill (e.g., mechanic,
electrician) allows an employee to maintain several
machine-types. On the other hand, maintenance of
any given machine-type requires a specific skill (e.g.,
a milling machine must be maintained by a
mechanic).
Practice 11 - answer
Emp Skill

A single employee can have multi skills. That is,


each employee can operate more than one machine.
- at most means maximum is one (according to
dictionary).

Can a skill itself operate machines?


Machine - Since any skills must be associated with
employees, a skill itself cannot operate any
machines.
Practice 12 – Recursive Relationship
 In our company, we have several departments with more than
1000 employees. Each department is managed by one person,
and must have a manager all the time by our corporate
regulations. We would like to keep the following information on
each department: department ID, department name, budget,
and location. Each employee is supervised directly by one
person, but each supervisor can manage many supervisees. As
for employees, we would like to keep the following information:
employee id, employee name, address, salary. Since data
management of our company is becoming so complex, we plan
to develop a database system to manage our current data
requirements described here.
Practice 12
 Attributes of Dept  Attributes of Emp
 Dept_ID  Emp_ID
 Dept_Name  Emp_Name
 Budget  Address
 Location  Salary
 (if Manager is included as  (If supervisor & Dept are
attribute, -3) included as attributes, -3
for each one)

Assumptions have to be stated in following cases:


• NO Optionality (-2 for each)
• supervisor
Practice 12

Dept
Emp
Practice 13-1
 Read the following case study, which describes
the data requirements for a video rental
company: The video rental company has several
branches throughout the USA. The data held on each
branch is the branch address made up of street, city,
state, and zip code, and the telephone number. Each
branch is given a branch number, which is unique
throughout the company. Each branch is allocated
staff, which includes a Manager. The Manager is
responsible for the day-today running of a given
branch. The data held on a member of staff is his or
her name, position, and salary.
Practice 13-2
 Each member of staff is given a staff number, which
is unique throughout the company. Each branch has
a stock of videos. The data held on a video is the
catalog number, video number, title, category, daily
rental, cost, status, and the names of the main
actors, and the director. The catalog number
uniquely identifies each video. However, in most
cases, there are several copies of each video at a
branch, and the individual copies are identified
using the video number. A video is given a category
such as Action, Adult, Children, Drama, Horror, or
Sci-Fi. The status indicates whether a specific copy
of a video is available for rent.
Practice 13-3
 Before hiring a video from the company, a customer
must first register as a member of a local branch. The
data held on a member is the first and last name,
address, and the date that the member registered at
a branch. Each member is given a member number,
which is unique throughout all branches of the
company. Once registered, a member is free to rent
videos, up to maximum of ten at any one time. The
data held on each video rented is the rental number,
the full name and number of the member, the video
number, title, and daily rental, and the dates the video
is rented out and date returned. The rental number is
unique throughout the company.
Real World Example 1
NCFCComp would like to keep track of their employees, departments and
projects. 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. A department controls a number of projects, each of
which has a unique name, a unique number and a single location. We
need to 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 need to keep track of the number of hours per
week that an employee works on each project. We also should keep track
of the direct supervisor of each employee. For insurance purposes, we
want to keep track of the dependents of each employee. We keep each
dependent's name, sex, birth date, and relationship to employee.
Real World Example 2
Direct Health Center (DHC) would like to hire you as consultant to
design a database for their medical center that employs several
physicians. Each physician has only one specialty. Patient records are
shared among the doctors. For each patient visit information is stored
about the type (regular office, hospital, after hours, house calls, etc.), a
single diagnosis for that visit, and the charge. A patient may visit more
than one of the doctors on a particular day. We assume, however, that a
patient never visits the same doctor more than once in one day. On each
doctor we would like to store his/her employee number (which is
unique), his/her full name and the doctor's specialty. For every patient
we would like to store his/her SSN, full name, age and
his/her diagnosis. If and when a patient is prescribed any medication,
we need to know the name of that medication, its dosage and who
prescribed it.
Real World Example 3

ProgLtd is a company that places computer programmers at


temporary jobs. They keep on each programmer: the programmer's
identification number, the programmer's last name, the programmer's
rank (Junior, Senior ...), his/her hourly rate and what languages the
programmer knows and how well he/she is experienced in that
language (the value should be recorded as a percentage). ProgLtd
deals with clients who may require programmers who know a
particular programming language and may request programmers who
are experience in such a programming language on a particular
platform (machine or environment). Once a programmer is assigned a
temporary job, ProgLtd would like to keep track of when he/she
started the job and the number of hours he/she is expected to spend
at such job. That is in addition to the client name and phone number
where the temp has been assigned. ProgLtd charges its clients a flat
rate of $7.00 over the programmer's hourly rate.
Self-Practice 2
 The Company has 30 instructors and can handle up
to 100 trainees per training course. The Company
offers five advanced technology courses, each of
which is taught by a teaching team of two or more
instructors. Each instructor is assigned to a maximum
of two teaching teams or may be assigned to do
research. A teaching team must have several
instructors per training session.
 Need some creativity
 Do we need to have a “company” entity? Why or why not?
Self-Practice 2 - Answer

Team Instructor Course

Put weak entity notation if PK of “Instructor” is a


combination of both “Team” and “Course” entity.

You might also like