Professional Documents
Culture Documents
Chapter 2- ERD
Chapter 2- ERD
PRODUCE
PURCHASED BY
FACTORY
CAR
CUSTOMER
ENTITY
The diagram above shows a car purchasing model that involves the relationship between the factory, car and customer. Here, we can see clearly that factory produces car and a customer purchases the car Entity : FACTORY, CAR & CUSTOMER Relationship : Produce & Purchased by.
Chapter 2- ERD
publish
Written by
Books at E-Book bookstore are recorded. Information about publisher and the author will also be recorded to make sure that the process of searching for the book is easier
Chapter 2- ERD
1 PUBLISHER publish
M
BOOK
city
Title
Publisher_Code
Relationship One to Many (1:M) : One publisher can publish many books while one book can only be published by one publisher
Chapter 2- ERD
Step 2 :
Book_Code
Author_No
Price
Type
Author_No
M
BOOK publish
N
AUTHOR
Title
Publisher_Code
Book_Code
Author_Name
Relationship Many to Many (M:N) : One book can be written by many authors while one author can write many books
Chapter 2- ERD
Complete ERD
Publisher_Code Publisher_Name Book_Code
Type Price
PUBLISHER
1
publish
M BOOK M
city
Publisher_Code
Title
Written by
Book_Code Author_No
N
AUTHOR
Author_No
Chapter 2- ERD
Author_Name
Element
Symbol
Definition
Entity
Attribute
A property or characteristic of
an entity or relationship type.
Relationship
Chapter 2- ERD
2.1.3 Notation of ER Model Entity Relationship Simple Attribute Multi valued Composite Attribute
Derived Attribute
Chapter 2- ERD
Chapter 2- ERD
Continue..
Characteristics of entities : Must have an attributes and unique key Will become a table in a database Classification of entities :
PERSON
PLACE
OBJECT
EVENT
Continue..
What is Entity Type ? Entity type is a collection of entities, which share the same characteristics What is Entity Instances ? Entity instances are data for entity type
Chapter 2- ERD
Example
Entity Type : BOOK
Attribute : Book_Code Book_title Publisher_Code
Two entity instances for BOOK : P01 Access 2000 Processing M-G1
Database
76.00 Yes P02 Concepts of Database Management
Description
Type Price Book_cover
P-H1
Database 100.00
Chapter 2- ERD
No
BOOK
Title
Attributes for the entity BOOK are Book_code, Type, Price and Title
Chapter 2- ERD
Definition
An attribute that holds a single value e.g: The majority of people have only one name An attribute that have more than one value e.g: A staff may have 2 tel_no. An attribute that can be broken down into component parts
Example
Name
Multi valued
Pnone-Num
Composite
Town
State
Postcode
Address
Derived
Date_of_birth Age
Chapter 2- ERD
Continue.
2.3.2 Cardinality Constraint Definition :The number of entity type, which is involved in a relationship.
Types of cardinality constraint : a). One to One Relationship (1:1)
1 MANAGER X
manage
1 BRANCH Y
An employee (manager) can manage only one branch at one time and each branch only has one manager.
Chapter 2- ERD
1 FACULTY X offer
M COURSE Y
At university, one faculty offers many courses for students but one course is offered by one faculty only.
Chapter 2- ERD
M BOOK
Written by
N AUTHOR
ISDN
A book may have more than one author and an author may write more than one Chapter 2- ERD book.
Primary Key
Foreign Key
Composite Key
Continue.
2.4.2 Integrity Constraints
2 types of integrity constraint a). Entity Integrity Requirement : All entries are unique and no part of a primary key may be null (no data).
Chapter 2- ERD
Continue.
b). Referential Integrity Requirement : If foreign key exist in one table then the foreign key value must reference an existing primary key value in a table to which it is related and it can be null.
Chapter 2- ERD
Example :
PUBLISHER
Publisher_Code F-B1 M-G1 P-H1 T-H1 Name Fajar Bakti McGraw Hill Prentice Hall Thompson City Malaysia UK UK US
BOOK
Book_Code P01 P02 Book_Title Access 2000 Processing Teach Yourself MS Access Publisher_Code M-G1 M-G1 Type Database Database Price 76.00 80.00
P03
P04 P05
P-H1
T-H1 F-B1
Database
Pengetahuan am Graphic
100.00
40.00 88.00
Publisher_Code is a Primary Key for PUBLISHER table, but it is also a Foreign Key for BOOK table. Please note that Foreign Key value in table BOOK must match the Primary Key value in PUBLISHER table. Chapter 2- ERD
Chapter 2- ERD
ADD ATTRIBUTES
Chapter 2- ERD
Exercise
Hospital Jaya is based in KL. This hospital has a few wards with several patients. This wards has a few types, which depends on type of patients.
Patient will be recorded into file that has ID Patient, Patient Name, Address, Phone Number, IC Number, Categories either VIP or regular patient and a group of blood patient
Each patient is treated by a doctor at one time but one doctor can treats a number of patients. The information of doctors recorded are : Doctor ID, name, address, phone number, IC number and specialization. The nurses will be assigned to take care of the patients. Nurses in this hospital are graded based on their experience, qualification and duration of working in the hospital.
Draw a complete ERD based on the situation
Chapter 2- ERD