You are on page 1of 32

ER MODEL

Lecture 3
ENTITY

• Entity is a thing in the real world with an independent existence


• Physical existence: person, car, house or employee
• Conceptual existence: company, job or university

2
Attributes

• Each entity has attributes—the particular properties that describe it.


• For example, an EMPLOYEE entity may be described by the employee’s
name, age, address, salary, and job.

3
Symbol

4
SAMPLE

5
ER MODEL

6
Composite Attributes

• Attributes that is divided into subpart or sub attributes

Attributes are not dividable are called


atomic or simple attribute

7
Retrieve and show the following information about manager
who joined in 1991-06-19

SSN Project_no Project_name Hours Dname Dloc Salary


888665555 20 Reorganization NULL Headquarters Huston 55000
• Operation:
Insert <‘Cecilia’, ‘F’, ‘Kolonsky’, ‘677678989’, ‘1960-04-05’, ‘6357
Windswept,Katy, TX’, F, 28000, ‘987654321’, 7> into EMPLOYEE.

• Operation:
Delete the EMPLOYEE tuple with Ssn = ‘999887777’.
ANS. Employee and Works_on
• Operation:
Update the Dno of the EMPLOYEE tuple with Ssn = ‘999887777’ to 7
ER Diagram
• An Entity Relationship Diagram (ERD) is a visual representation of different
data using conventions that describe how these data are related to each other.

For example, the elements writer, novel, and consumer may be described using
ER diagrams this way:
• An inventory software used in a retail shop will have a database that monitors
elements such as purchases, item, item type, item source and item price.
Rendering this information through an ER diagram would be something like
this:
HISTORY

• Entity-Relationship model initially proposed by Peter Chen in 1976 to create a


uniform convention that considers both relational database and network
views.

• Chen envisioned the ER model as a conceptual modeling approach that views


real world data as systems of entities and relationships. Entities are data
objects that maintain different relationships with each other.
Weak Entity

• A weak entity is an entity that depends on the existence of another entity.

• In more technical terms it can defined as an entity that cannot be identified by


its own attributes.

• It uses a foreign key combined with its attributed to form the primary key.

• An entity like order item is a good example for this. The order item will be
meaningless without an order so it depends on the existence of order.
Composite Attribute
• Attributes can also have their own specific attributes
Multivalued Attribute

• If an attribute can have more than one value it is called an multivalve attribute.
• It is important to note that this is different to an attribute having its own
attributes.
• For example a teacher entity can have multiple subject values.
Derived Attribute
• An attribute based on another attribute. This is found rarely in ER diagrams.

• For example for a circle the area can be derived from the radius.
21
22
23
24
Requirement

"The system will manage author's and loaner's information, and


keep track of books loaned. The borrower's information include
name, address, e-mail, and phone. The author's information
include name, address and e-mail.

New books, authors and clients are entered into the system.
When a client checks out a book, the system will register the
date the book was loaned and calculate the days the book can be
loaned. It will also calculate the date the book is due to be
returned. If the borrower returns the book late, he must pay a
fine based on the number of days overdue."

25
Requirement
"I would like my customers to be able to browse my catalog of books and place
orders over the Internet. Currently, I take orders over the phone. I have mostly
corporate customers who call me and give me the ISBN number of a book and a
quantity; they often pay by credit card.

I then prepare a shipment that contains the books they ordered. If I don't have
enough copies in stock, I order additional copies and delay the shipment until
the new copies arrive; I want to ship a customer's entire order together.

My catalog includes all the books I sell. For each book, the catalog contains its
ISBN number, title, author, purcha.se price, sales price, and the year the book
was published. Most of my customers are regulars, and I have records with their
names and addresses.

New customers have to call me first and establish an account before they can
use my website. On my new website, customers should first identify themselves
by their unique customer identification number. Then they should be able to
browse my catalog and to place orders online."
26
Recursive Relationships

27
Cardinality Ratios for Binary Relationship

At any point in time—an employee can manage


one department only and a department can have one manager only
28
N:1 Relationship

N 1

29
M:N Relationship

An employee can
work on
several projects and
a project can have
several employees.

30
Participation constraint

• The participation constraint specifies whether the existence of an entity depends


on its being related to another entity via the relationship type

• There are two types of participation constraints—total and partial

• If a company policy states that every employee must work for a department, then an
employee entity can exist only if it participates in at least one WORKS_FOR
relationship instance.

Thus, the participation of EMPLOYEE in WORKS_FOR is called total participation,


meaning that every entity in the total set of employee entities must be related to a
department entity via WORKS_FOR… displayed as a double line

• We do not expect every employee to manage a department, so the participation of


EMPLOYEE in the MANAGES relationship type is partial, meaning that some or part
of the set of employee entities are related to some department entity via MANAGES,
but not necessarily all
31
recursive relationships

32

You might also like