Notes and Exercises On ERD
Notes and Exercises On ERD
Attributes, which are represented by ovals. A key attribute is the unique, distinguishing
characteristic of the entity. For example, an employee's social security number might be
the employee's key attribute.
A multivalued attribute can have more than one value. For example, an employee entity
Identify the entities. The first step in making an ERD is to identify all of the entities you
will use. An entity is nothing more than a rectangle with a description of something that
your system stores information about. This could be a customer, a manager, an invoice,
a schedule, etc. Draw a rectangle for each entity you can think of on your page. Keep
them spaced out a bit.
Identify relationships. Look at two entities, are they related? If so draw a solid line
connecting the two entities.
Describe the relationship. How are the entities related? Draw an action diamond
between the two entities on the line you just added. In the diamond write a brief
description of how they are related.
Add attributes. Any key attributes of entities should be added using oval-shaped
symbols.
Complete the diagram. Continue to connect the entities with lines, and adding diamonds
to describe each relationship until all relationships have been described. Each of your
entities may not have any relationships, some may have multiple relationships. That is
okay.
Example to illustrate the major rules in mapping ER to relational
schema:
The following ER has been designed to represent the requirement of an organization to capture
Employee Department and Project information. And Employee works for department where an
employee might be assigned to manage a department. Employees might participate on different
projects within the organization. An employee might as well be assigned to lead a project where
the starting and ending date of his/her project leadership and bonus will be registered.
After we have drawn the ER diagram, the next thing is to map the ER into relational schema so as the
rules of the relational data model can be tested for each relational schema. The mapping can be done
for the entities followed by relationships based on the rule of mapping. the mapping has been done
as follows.
Steps of Normalization:
First Normal Form (1NF)
Requires that all column values in a table are atomic (e.g., a number is an atomic value, while a
list or a set is not).
Putting each repeating group into a separate table and connecting them with a primary key-
foreign key relationship
Exercises
Draw ERD for the following cases and map the ERD in to Relation
1. An internet sales organization takes items produced by different companies and sells the items
to customers based on their order.
2. In a hospital system, a patient undergoes procedures based on the order of the doctor. A
procedure has a code and fee. A patient has personal details and medical details. A doctor has
name and specialty.
3. A writer writes books and customers buy it.
4. Exam attendees choose from number of exams from and exam management system and sit for
an exam. After the examination is done, the record number, exam subject, name and score is
automatically recorded in the database.
5. A student record management system will have the following two basic data object categories
with their own features or properties: Students will have an Id, Name, Dept, Age, GPA and Course
will have an Id, Name, Credit Hours. Whenever a student enroll in a course in a specific Academic
Year and Semester, the Student will have a grade for the course.
6. A Personnel record management system will have the following two basic data object categories
with their own features or properties: Employee will have an Id, Name, DoB, Age, Tel and
Department will have an Id, Name, Location. Whenever an Employee is assigned in one
Department, the duration of his stay in the respective department should be registered.
7. And Employee works for department where an employee might be assigned to manage a
department. Employees might participate on different projects within the organization. An
employee might as well be assigned to lead a project where the starting and ending date of his/her
project leadership and bonus will be registered.
8. Consider the following set of requirements for a university database that is used to keep track of
students’ transcripts.
The university keeps track of each student’s name, student number, social security number,
current address and phone, permanent address and phone, birthdate, sex, class (freshman,
sophomore, . . ., graduate), major department, minor department (if any), and degree program
(B.A., B.S., . . ., Ph.D.). Some user applications need to refer to the city, state, and zip code of the
student’s permanent address and to the student’s last name. Both social security number and
student number have unique values for each student.
Each department is described by a name, department code, office number, office phone, and
college. Both name and code have unique values for each department.
Each course has a course name, description, course number, number of semester hours, level,
and offering department. The value of course number is unique for each course.
Each section has an instructor, semester, year, course, and section number. The section number
distinguishes sections of the same course that are taught during the same semester/year; its
values are 1, 2, 3, . . ., up to the number of sections taught during each semester.
A grade report has a student, section, letter grade, and numeric grade (0, 1, 2, 3, or 4).
9. Normalize the following table in to first normal form
Employee Age Department
Melvin 32 Marketing, Sales
Edward 45 Quality Assurance
Alex 36 Human Resource