ERD ( ANS)Mazharjaved2001@yahoo.com1 Conceptual data model From the statement of data requirements a...

Post on 05-Jan-2016

213 views 0 download

Transcript of ERD ( ANS)Mazharjaved2001@yahoo.com1 Conceptual data model From the statement of data requirements a...

ERD ( ANS) Mazharjaved2001@yahoo.com 1

Conceptual data modelFrom the statement of data requirements a conceptual data model

is produced. This describes how the data elements in the database are to be grouped. Three terms are used to describe the data requirements:

Entity • An entity is a thing of interest to an organisation about which data is

to be held

Attribute:• An attribute is a property or characteristic of an entityRelationship:

• A relationship is a link or association between entities

ERD ( ANS) Mazharjaved2001@yahoo.com 2

Person, place, object, event or concept about which data is to be maintained

named property or characteristic of an entity

Association between the instances of one or more entity types

Represents a set or collection of objects in the real world that share the same properties

EntityName Verb Phrase AttributeName

ERD ( ANS) Mazharjaved2001@yahoo.com 3

Entities

• Examples of entities:– Person: EMPLOYEE, STUDENT, PATIENT– Place: STORE, WAREHOUSE– Object: MACHINE, PRODUCT, CAR– Event: SALE,REGISTRATION, RENEWAL– Concept: ACCOUNT, COURSE

• Guidelines for naming and defining entity types:– An entity type name is a singular noun– An entity type should be descriptive and specific – An entity name should be concise– Event entity types should be named for the result of the event, not

the activity or process of the event.

ERD ( ANS) Mazharjaved2001@yahoo.com 4

Attributes

• Example of entity types and associated attributes:STUDENT: Student_ID, Student_Name, Home_Address,

Phone_Number, Major

• Guidelines for naming attributes:– An attribute name is a noun.

– An attribute name should be unique

– To make an attribute name unique and clear, each attribute name should follow a standard format

– Similar attributes of different entity types should use similar but distinguishing names.

ERD ( ANS) Mazharjaved2001@yahoo.com 5

Relationships

Associations between instances of one or more entity types that is of interest

Given a name that describes its function.

• relationship name is an active or a passive verb.

Associations between instances of one or more entity types that is of interest

Given a name that describes its function.

• relationship name is an active or a passive verb.

Author Book

Relationship name: writes

An author writes one or more booksA book can be written by one or more authors.

ERD ( ANS) Mazharjaved2001@yahoo.com 6

• One-to-one

• Eg Products in a supermarket each have a unique barcode number.

• One-to-many

• Eg A video club member may hire out a number of videos.

• Many-to-many

• Teachers and pupils in a school. Each teacher teaches many pupils and each pupil has many teachers.

Types of relationship

ERD ( ANS) Mazharjaved2001@yahoo.com 7

Types of relationship

• One to One.• 1. A department in school is led up by an individual

person, and this person only leads one department.• One to Many• The head of department may be in charge of many staff,

but these staff only have one head of department.• Many to Many• A teacher may order many books, but each book could

be ordered by many teachers.

ERD ( ANS) Mazharjaved2001@yahoo.com 8

Entity-relationship diagrams• An entity-relationship diagram is a diagrammatic way

of representing the relationships between the entities in a database.

Employee Company cardrives

(One-to-one)

Ward Patientholds

(One-to-many)

Album Singersfeatures

(Many-to-many)

ERD ( ANS) Mazharjaved2001@yahoo.com 9

Data Requirements for a Hospital In-patient System

• A hospital is organised into a number of wards. • Each ward has a ward number and a name recorded, along with a

number of beds in that ward. • Each ward is staffed by nurses. • Nurses have their staff number and name recorded, and are

assigned to a single ward.• Each patient in the hospital has a patient identification number, and

their name, address and date of birth are recorded. • Each patient is under the care of a single consultant and is assigned

to a single ward. • Each consultant is responsible for a number of patients. Consultants

have their staff number, name and specialism recorded.

ERD ( ANS) Mazharjaved2001@yahoo.com 10

Entity Relationship Diagram

• Entity ( identifier ) • Ward Ward Id • Nurse Staff id • Patient Patient id • Consultant Staff id

Ward Patientholds

(One-to-many)

Nurse Consultant

SeesStaffed by

ERD ( ANS) Mazharjaved2001@yahoo.com 11

Scenario

• Each semester, each student must be assigned an advisor who counsels students about degree requirements and helps the students register for classes.

• Each student must register for classes with the help of an advisor, but if the student’s assigned advisor is not available, the student may register with any advisor.

• We must keep track of students, the assigned advisor for each, and the name of the advisor with whom the student registerd for the current term.

ERD ( ANS) Mazharjaved2001@yahoo.com 12

ERD For Scenario

ERD ( ANS) Mazharjaved2001@yahoo.com 13

Scenario

• A course is always taught by some teacher.

• A teacher cannot exist without corresponding course. A course may be taught by at least one or more teachers.

• On the other hand, a teacher may teach at least one or more courses.

• Draw ERD diagram ???

ERD ( ANS) Mazharjaved2001@yahoo.com 14

Scenario 2

• Each department has a chairman while a chairman chairs only one department.

• The relationship between department and chairman will be what??