Database Engineering (EC-240) : Lab Manual # 04

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

DATABASE ENGINEERING
(EC-240)
LAB MANUAL # 04
Course Instructor: Prof Dr Farooque Azam / Assoc Prof Dr Wasi Haider Butt
Lab Engineer: Engineer Kashaf Raheem

Student Name: Amina Qadeer

Degree/ Syndicate: _DE-42-A


College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

Lab#04: More on Entity Relationship Diagram

Lab Objective:
To introduce students with types of entities, attributes, and relationships.

Lab Tasks:

1. Draw an ER diagram for the following data.


Consider the following information about the university data base.
• Professors have an SSN, a name, an age, a rank and a research specialty.
• Projects have a project number, a sponsor name, a starting date and ending
date and the budget.
• Graduate students have an SSN, a name, an age and a degree program (MS
or PhD).
• Each project is managed by one professor (known as the project’s principal
investigator).
• Each project is work on by one or more professors (known as the project’s
coinvestigators).
• Professors can manage and /or work on multiple projects.
• Each project is work on by one or more graduate students (known as the
project’s research assistants)
• When graduate student work on a project, a professor must supervise their
work on the project. Graduate students can work on multiple projects, in
which case they will have supervisor for each one (potentially different).
• Departments have a department no., a department name and main office.
• Departments have a professor known as a (chairman) who runs the
department.
• Professors work in one or more departments, and for each department that
they work in, a time percentage is associated with their job.

• Graduate students have one major department in which they are working on
their degree.
• Each graduate student has another, more senior graduate student (known as
a student advisor) who advises him or her on what courses to take.
College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

2. Draw an ER diagram.
Assume that at Pine Valley Furniture each product (described by product number,
description, and cost) comprises at least three components (described by
component number, description, and unit of measure), and components are used to
make one or many products. In addition, assume that components are used to make
other components and that raw materials are also considered to be components. In
both cases of components, we need to keep track of how many components go into
making something else.
College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

3. Consider the following set of requirements draw an ER diagram. Specify


key attributes of each entity type.

Each publisher has a unique name; a mailing address and telephone number are also
kept on each publisher. A publisher publishes one or more books; a book is
published by exactly one publisher. A book is identified by its ISBN, and other
attributes are title, price, and number of pages. Each book is written by one or more
authors; an author writes one or more books, potentially for different publishers.
Each author is uniquely described by an author ID, and we know each author’s

name and address. Each author is paid a certain royalty rate on each book he or she
authors, which potentially varies for each book and for each author. An author
receives a separate royalty check for each book he or she writes. Each check is
identified by its check number, and we also keep track of the date and amount of
each check. As you develop the ERD for this problem, follow good data naming
guidelines.

Understanding rough sketch :


College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering


College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

4. Consider the following set of requirements draw an ER diagram. Specify


key attributes of each entity type.
Companies, identified by Company ID and described by Company Name and
Industry Type, hire consultants, identified by Consultant ID and described by
Consultant Name, Consultant Specialty, which is multivalued. Assume that a
consultant can work for only one company at a time, and we need to track only
current consulting engagements. Draw an ERD for this situation. Now, consider a
new attribute, Hourly Rate, which is the rate a consultant charges a company for
each hour of his or her services. Redraw the ERD to include this new attribute.
Now, consider that each time a consultant works for a company, a contract is
written describing the terms for this consulting engagement. Contract is identified
by a composite identifier of Company ID, Consultant ID, and Contract Date.
Assuming that a consultant can still work for only one company at a time, redraw
the ERD for this new situation. Did you move any attributes to different entity types
in this latest situation? As a final situation, now consider that although a consultant
can work for only one company at a time, we now need to keep the complete history
of all consulting engagements for each consultant and company. Draw an ERD for
College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

this final situation. Explain why these different changes to the situation led to
different data models, if they did.

5. Prepare an ERD for a real estate firm that lists property for sale. Also
prepare a definition for each entity type, attribute, and relationship on
your diagram. In addition, draw a data model for this situation using the
tool you have been told to use in your course. The following describes this
organization:

• The firm has a number of sales offices in several states. Attributes of sales
office include Office Number (identifier) and Location.
• Each sales office is assigned one or more employees. Attributes of
employee include Employee ID (identifier) and Employee Name. An
employee must be assigned to only one sales office.
• For each sales office, there is always one employee assigned to manage that
office. An employee may manage only the sales office to which he or she is
assigned.
• The firm lists property for sale. Attributes of property include Property ID
(identifier) and Location. Components of Location include Address, City,
State, and Zip Code.
College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

• Each unit of property must be listed with one (and only one) of the sales
offices. A sales office may have any number of properties listed or may
have no properties listed.
• Each unit of property has one or more owners. Attributes of owners are
Owner ID (identifier) and Owner Name. An owner may own one or more
units of property. An attribute of the relationship between property and
owner is Percent Owned.

6. Draw an ERD for the following situation .


Projects, Inc., is an engineering firm with approximately 500 employees. A
database is required to keep track of all employees, their skills, projects assigned,
and departments worked in. Every employee has a unique number assigned by the
firm and is required to store his or her name and date of birth. If an employee is
currently married to another employee of Projects, Inc., the date of marriage and
who is married to whom must be stored; however, no record of marriage is required
if an employee’s spouse is not also an employee. Each employee is given a job title
(e.g., engineer, secretary, and so on). An employee does only one type of job at any
given time, and we only need to retain information for an employee’s current job.
There are 11 different departments, each with a unique name. An employee can
report to only 1 department. Each department has a phone number. To procure
various kinds of equipment, each department deals with many vendors. A vendor
College of Electrical & Mechanical Engineering, NUST

Department of Computer Engineering

typically supplies equipment to many departments. We are required to store the


name and address of each vendor and the date of the last meeting between a
department and a vendor. Many employees can work on a project. An employee
can work on many projects (e.g., Southwest Refinery, California Petrochemicals,
and so on) but can only be assigned to at most one project in a given city. For each
city, we are interested in its state and population. An employee can have many
skills (preparing material requisitions, checking drawings, and so on), but she or
he may use only a given set of skills on a particular project. (For example, an
employee MURPHY may prepare requisitions for the Southwest Refinery project
and prepare requisitions as well as check drawings for California Petrochemicals.)
Employees use each skill that they possess in at least one project. Each skill is
assigned a number, and we must store a short description of each skill. Projects are
distinguished by project numbers, and we must store the estimated cost of each
project.

You might also like