• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
D I T211    Chapter 3
 

D I T211 Chapter 3

on

  • 3,585 views

 

Statistics

Views

Total Views
3,585
Views on SlideShare
3,584
Embed Views
1

Actions

Likes
1
Downloads
0
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    D I T211    Chapter 3 D I T211 Chapter 3 Presentation Transcript

    • Chapter 3 Entity Relationship Modelling
    • Objectives
      • At the end of this chapter, students should be able to:
      • Understand the basic concept of Entity Relationship (ER) model that consists of elements and notation.
      • Identify entities, attributes and attribute-types.
      • Identify the relationship and cardinality constraint.
      • Identify the relation key and integrity constraint.
      • Define Entity Relationship (ER) Diagram.
      • Create an ER diagram using the step by step approach.
    • Introduction
      • Entity Relationship (ER) diagram is a graphical diagram used at the design stage of database system’s development for gathering data.
      • ER diagram consists of three elements, which are entities , attributes and relationship , and they are each associated to a notation or symbol for constructing a meaningful ER diagram.
      • Entity Relationship Modeling is a process used to help us to understand and document the informational requirements of a system.
      • A database system is normally built according to three major stages:
        • 1. requirements
        • 2. design
        • 3. implementation
    • ER Model & ER Diagram
      • The Entity Relation model is presented using the ER diagram.
      • Entity relationship diagram is a graphical diagram that depicts entity relationship model that comprises entities, attributes and relationship . It also displays connectivity and cardinality .
    • Elements of ER Model
      • There are 3 elements of ER Model:
      • Entities
      • Attributes (which include: simple, multivalue, composite, derived)
      • Relationship
    • Elements of ER Model (cont.)
      • ENTITY
        • Definition
          • Entity is a person, place, object, event or concept, which you want to store the information in a table.
        • Characteristics of an entity
          • Must have a set of attributes
          • Will become a table in a database
        • Examples of entity
    • Elements of ER Model (cont.)
      • ENTITY
        • What is entity type?
          • A collection of entities that shares the same characteristics.
        • What is entity instance?
          • Data for entity types.
        • Example of entity type and entity instance
    • Elements of ER Model (cont.)
      • ATTRIBUTE
        • Definition
          • Attributes are the characteristics of an entity or objects
          • Attribute has a name and data type.
    • Elements of ER Model (cont.)
    • Elements of ER Model (cont.)
      • ATTRIBUTE
        • Example
    • Elements of ER Model (cont.)
      • RELATIONSHIP
      • A relationship, which is an association between entities, is defined by a diamond shaped symbol in an ER diagram.
      • The relationship that is depicted by a diamond is labelled with verb or verb phrase.
    • Cardinality Constraint
      • Definition: The number of entity type, which is involved in a relationship.
      • Types of cardinality constraints
      • a) One to One Relationship (1:1)
        • Definition : Maximum one X for each Y and 1 Y for each X.
      Primary key
    • Cardinality Constraint (cont.)
      • b) One to Many Relationship (1:M)
        • Definition: Maximum one X for each Y and possibly many Y’s for each X.
      Primary key Foreign key
    • Cardinality Constraint (cont.)
      • c) Many to One Relationship (M:1)
        • Definition: Possibly many X’s for each Y and maximum one Y for each X.
      Primary key Foreign key
    • Cardinality Constraint (cont.)
      • d) Many to Many Relationship (M:N)
        • Definition: Possibly many X’s for each Y and many Y’s for each X.
      Composite entity Composite keys
    • E R Diagram
      • Example 1
    • E R Diagram (cont.)
    • E R Diagram (cont.)
      • Example 2
    • E R Diagram (cont.)
    • Relational Key
      • Relational Key Definition
        • A key consists of one or more attributes that can be identified in a row.
        • Relational key is an attribute that relates one entity with another entity in a relationship.
      • Why we need Relational Key?
        • Relational key enables us to link the tables together in a database for easier data access storage.
    • Relational Keys (cont.)
      • Types of Relational Keys
    •  
    • Integrity Rules
      • Two types of integrity constraint are Entity Integrity and Referential Integrity .
      • a) Entity Integrity
        • Requirement:
          • All entries are unique and no part of a primary key may be null.
        • Purpose:
          • Guarantees that each entity will have a unique identity and ensures that foreign key values can properly refer to primary key values.
    • Integrity Rules (cont.)
      • b) Referential Integrity
        • Referential integrity is a set of rules that prevents you from changing or deleting a record if matching records exist in a related table.
        • 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.
        • Purpose :
          • Possibility for non-corresponding value, but impossible for invalid entity.
          • Referential integrity rule disables row deletion of a table consisting primary key matching key values in another table.
    •  
    • Steps to Develop ERD
    • Examples
      • Example 1
      • A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one department. Project will be given to the employee and it will be done in a group. At least one employee is assigned to one project or more. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number, department code and a unique project number.
    • Examples (cont.)
      • Example 2
      • Create an ER diagram for the following requirements with the appropriate attributes for each entity type and structural constraints for each relationship type.
        • An INVOICE is written by a SALESREP. Each sales representative can write many invoices, but each invoice is written by a single sales representative.
        • (b) The INVOICE is written for a single CUSTOMER. However, each customer can have many invoices.
        • (c) An INVOICE can include many details (DETAIL-LINES), which describe the products bought by the customer.
        • (d) The product information is stored in a PRODUCT entity.
    • Examples (cont.)
      • Example 3
      • You have been requested by a travel agency, EXEL Travels, to build a database for storing information on customers and vacation package that have been booked. Create an ER Diagram based on the information below:
        • Each customer has information like Customer Number, Name, Address and Telephone number.
        • Customers may have many addresses and telephone numbers.
        • A customer may book more than one holiday package and one holiday package may also be booked by many customers.
        • Examples of payments according to booked holiday package :
          • Package A : New Zealand (3 days) - RM 3500
          • Package B : New Zealand (7 days) - RM 5000
          • Package C : New Zealand (10 days) - RM5990
    • Examples (cont.)
      • Example 4
      • Hospital Jaya is based in Kuala Lumpur. This Hospital has a few wards with several patients. This ward has a few types, which depends on types of patients.
      • Patients will be recorded into file that have 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 is: 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.
    • Examples (cont.)
      • Example 5