+ All Categories
Home > Documents > Erd Concepts

Erd Concepts

Date post: 26-Nov-2014
Category:
Upload: ahmad-gulzar
View: 136 times
Download: 3 times
Share this document with a friend
Popular Tags:
100
Naveed Anwer Butt @ UOG -April 2009 ek 7: Slide 1 of 46 Database systems-Systems Development Over Database Design Overview
Transcript
Page 1: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 1 of 46

Database systems-Systems Development Overview

Database Design Overview

Page 2: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 2 of 46

Database systems-Systems Development Overview

Overview - important points

• Some introductory information• ERD diagrams• Normalization• Other stuff

Page 3: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 3 of 46

Database systems-Systems Development Overview

SDLC - Where are we?

1. Systems planning phase

2. Systems analysis phase

3. Systems design phase

4. Systems implementation phase

5. Systems operation, support, and security phase

Data design

Page 4: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 4 of 46

Database systems-Systems Development Overview

Overview of Database Design

– What are the entities and relationships in the enterprise?

– What information about these entities and relationships should we store in the database?

– What are the integrity constraints or business rules that hold?

– A database `schema’ in the ER Model can be represented pictorially (ER diagrams).

– Can map an ER diagram into a relational schema.

Page 5: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 5 of 46

Database systems-Systems Development Overview

Data modeling versus Data design

• Data modeling - DFD diagrams– What data is needed

• Data design– How will the data be stored and retrieved

Page 6: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 6 of 46

Database systems-Systems Development Overview

Database Design

• Three phases of database design:

– Conceptual database design– Logical database design– Physical database design.

© Pearson Education Limited 1995, 2005

Page 7: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 7 of 46

Database systems-Systems Development Overview

Conceptual Database Design

• Process of constructing a model of the data used in an enterprise, independent of all physical considerations.

• Data model is built using the information in users’ requirements specification.

• Conceptual data model is source of information for logical design phase.

© Pearson Education Limited 1995, 2005

Page 8: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 8 of 46

Database systems-Systems Development Overview

Logical Database Design

• Process of constructing a model of the data used in an enterprise based on a specific data model (e.g. relational), but independent of a particular DBMS and other physical considerations.

• Conceptual data model is refined and mapped on to a logical data model.

Page 9: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 9 of 46

Database systems-Systems Development Overview

Physical Database Design

• Process of producing a description of the database implementation on secondary storage.

• Describes base relations, file organizations, and indexes used to achieve efficient access to data. Also describes any associated integrity constraints and security measures.

• Tailored to a specific DBMS system.© Pearson Education Limited 1995, 2005

Page 10: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 10 of 46

Database systems-Systems Development Overview

Overview of Database Design

• Conceptual design: (ER Model is used for this.)– What are the entities and relationships we need?

• Logical design:– Transform ER design to Relational Schema

• Schema Refinement: (Normalization)– Check relational schema for redundancies and related

anomalies.• Physical Database Design and Tuning:

– Consider typical workloads; (sometimes) modify the• database design; select file types and indexes.

Page 11: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 11 of 46

Database systems-Systems Development Overview

Storage choices

• File based– Text-based - XML– Binary

• Database systems– Relational– Object-based/oriented

Page 12: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 12 of 46

Database systems-Systems Development Overview

Databases

• Textbook says a few strange things– Most databases are relational– Most OO systems use an OO/relational mapping– DMBSs can run on fairly standard computers

• Microsoft Access - is not really a DBMS

Page 13: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 13 of 46

Database systems-Systems Development Overview

Database design a skill

• Data design usually involves the design of the database tables and fields

• Not always a straight forward task• We'll use entity relationship diagrams

Page 14: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 14 of 46

Database systems-Systems Development Overview

Introduction

• Entity Relationship Modelling (ERM) – a technique used to analyze & model the data in

organizations using an Entity Relationship (E-R) diagram.

• Entity-Relationship Model( E-Model)– A logical representation of the data for an

organization or for a business area.• Entity-Relationship diagram (E-R diagram)

– A graphical representation of an entity-relationship model.

Page 15: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 15 of 46

Database systems-Systems Development Overview

Why ERDs?

• Entity Relationship Diagrams are a major data modeling tool and will help organize the data in your project

• This process has proved to enable the analyst to produce a good database structure so that the data can be stored and retrieved in a most efficient manner.

• By using a graphical format it may help communication about the design between the designer and the user and the designer and the people who will implement it.

Page 16: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 16 of 46

Database systems-Systems Development Overview

ER diagram of Branch user views of DreamHome

Page 17: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 17 of 46

Database systems-Systems Development Overview

Page 18: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 18 of 46

Database systems-Systems Development Overview

Entity relationship diagram (ERD)

A data model utilizing several notations to depict data in terms of the entities and relationships described by that data.

Page 19: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 19 of 46

Database systems-Systems Development Overview

Background

• Introduced by Peter Chen in ‘75• Used to describe the element in the

system and their relationships• now widely used

Page 20: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 20 of 46

Database systems-Systems Development Overview

ERD Concepts - Entity

• Anything real or abstract about which we will store data

• Five classes: – Roles– events– Locations– tangible things– concepts

Page 21: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 21 of 46

Database systems-Systems Development Overview

Entity in ERD

• Entities– An entity is anything real or abstract about which we want to store

data. In short, anything, which an organization needs to store data about

– Entity types fall into five classes• Roles

e.g. Employee, Student• Events

e.g. Payment, Borrow• Locations

e.g. Campus, City• Tangible things or concepts

e.g. Department, Book

Page 22: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 22 of 46

Database systems-Systems Development Overview

Persons: agency, contractor, customer, department, division, employee, instructor, student, supplier.

Places: sales region, building, room, branch office, campus.

Objects: book, machine, part, product, raw material, software license, software package, tool, vehicle model, vehicle.

Events: application, award, cancellation, class, flight, invoice, order, registration, renewal, requisition, reservation, sale, trip.

Concepts: account, block of time, bond, course, fund, qualification, stock.

Data Modeling Concepts: Entity

Entity – a class of persons, places, objects, events, or concepts about which we need to capture and store data.

– Named by a singular noun

Page 23: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 23 of 46

Database systems-Systems Development Overview

What Should an Entity Be?

• SHOULD BE:– An object that will have many instances in the

database– An object that will be composed of multiple

attributes– An object that we are trying to model

• SHOULD NOT BE:– A user of the database system – An output of the database system (e.g. a report)

Page 24: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 24 of 46

Database systems-Systems Development Overview

Concepts of the ER Model

• Entity types

• Relationship types

• Attributes

© Pearson Education Limited 1995, 2005

Page 25: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 25 of 46

Database systems-Systems Development Overview

Entity Type

• Entity type– Group of objects with same properties, identified by

enterprise as having an independent existence. – A name/label assigned to items/objects that exist in

an environment and that have similar properties

• Entity Instances/occurrence– A single occurrence of an entity type– Uniquely identifiable object of an entity type.

• Entity set– A collection of similar entities. E.g., all employees

Page 26: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 26 of 46

Database systems-Systems Development Overview

Data Modeling Concepts: Entity

Entity instance – a single occurrence of an entity.

Student ID Last Name First Name

2144 Arnold Betty

3122 Taylor John

3843 Simmons Lisa

9844 Macy Bill

2837 Leath Heather

2293 Wrench Tim

instances

entityEntity Type STUDENT with instances

Page 27: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 27 of 46

Database systems-Systems Development Overview

Examples of Entity Types

© Pearson Education Limited 1995, 2005

Page 28: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 28 of 46

Database systems-Systems Development Overview

Entity Instance & Set

• A particular object belonging to a particular entity type

• Entity Type: Employee• Entity Instance: M. Sharif• Entity Set: All employees

Page 29: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 29 of 46

Database systems-Systems Development Overview

Data Modeling Concepts: Attributes

Attribute: Entities are further described by their attributes (also called data elements)

– A characteristics common to all or most instances of an entity– property or characteristic of an entity type– a descriptive property or characteristic of an entity. Synonyms include element, property, and field.

• Just as a physical student can have attributes, such as hair color, height, etc., data entity has data attributes

Page 30: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 30 of 46

Database systems-Systems Development Overview

Classifications of attributes:

– Simple versus Composite Attribute– Single-Valued versus Multivalued Attribute– Stored versus Derived Attributes

Page 31: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 31 of 46

Database systems-Systems Development Overview

31

Attributes

• Simple Attribute– Attribute composed of a single component

with an independent existence.

• Composite Attribute– Attribute composed of multiple components,

each with an independent existence.

© Pearson Education Limited 1995, 2005

Page 32: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 32 of 46

Database systems-Systems Development Overview

32

Attributes

• Single-valued Attribute– Attribute that holds a single value for each

occurrence of an entity type.

• Multi-valued Attribute– Attribute that holds multiple values for each

occurrence of an entity type.

© Pearson Education Limited 1995, 2005

Page 33: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 33 of 46

Database systems-Systems Development Overview

33

Attributes

• Derived Attribute– Attribute that represents a value that is

derivable from value of a related attribute, or set of attributes, not necessarily in the same entity type.

© Pearson Education Limited 1995, 2005

Page 34: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 34 of 46

Database systems-Systems Development Overview

Relationships in ERD

• Relationships– A data relationship is a natural association that exist

between one or more entities

Example

EMPLOYEE works in DEPARTMENT

EQUIPMENT is allocated to PROJECT

ESTEEM is a type of CAR

Page 35: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 35 of 46

Database systems-Systems Development Overview

Relationship Types

• Relationship type– A meaningful associations among entity

types.

• Relationship occurrence– Uniquely identifiable association, which

includes one occurrence from each participating entity type.

© Pearson Education Limited 1995, 2005

Page 36: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 36 of 46

Database systems-Systems Development Overview

ERD Concepts - Relationship

• Relationships have cardinality– The number of occurrences of one entity

for a single occurrence of the related entity

Page 37: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 37 of 46

Database systems-Systems Development Overview

One-to-one Relationships

• Three types of relationship exist between two different entities

• It is also called the cardinality (the number of occurrences of one entity for a single occurrence of the related entity)

– One-to-one relationship

– One-to-many relationship

– Many-to-many relationship

Page 38: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 38 of 46

Database systems-Systems Development Overview

Cardinality of Relationships

• One – to – One– Each entity in the relationship will have exactly

one related entity• One – to – Many

– An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity

• Many – to – Many– Entities on both sides of the relationship can have

many related entities on the other side

Page 39: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 39 of 46

Database systems-Systems Development Overview

One-to-one Relationships

• This type of relationship takes place when a single occurrence of an entity is related to just one occurrence of a second entity

Example:

PERSON owns a CAR

CAR is owned by a PERSONPerson

C ar

owns

Person

C ar

own by

Page 40: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 40 of 46

Database systems-Systems Development Overview

One-to-many Relationships

• This type of relationship takes place when a single occurrence of an entity is related to many occurrence of a second entity

Example:

DEPARTMENT has EMPLOYEE EMPLOYEE works in DEPARMENT

D epartm ent

Em ployee

has

D epartm ent

Em ployee

works in

Page 41: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 41 of 46

Database systems-Systems Development Overview

Many-to-many Relationships

• This type of relationship takes place when many occurrence of an entity are related to many occurrence of a second entity

Example:

STAFF work in PROJECT PROJECT assigned to STAFF

Staff

P ro ject

works in

Staff

P ro ject

assigned to

Page 42: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 42 of 46

Database systems-Systems Development Overview

Key Constraints (Contd.)

• Several types of key-constraints:

Many-to-Many1-to-1 1-to Many Many-to-1

Page 43: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 43 of 46

Database systems-Systems Development Overview

Cardinality Constraints

• Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity.

• Minimum Cardinality– If zero, then optional– If one or more, then mandatory

• Maximum Cardinality– The maximum number

Page 44: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 44 of 46

Database systems-Systems Development Overview

Data Modeling Concepts: Degree

Degree – the number of entities that participate in the relationship.

A relationship between two entities is called a binary relationship.

A relationship between three entities is called a 3-ary or ternary relationship.

A relationship between different instances of the same entity is called a recursive relationship.

Page 45: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 45 of 46

Database systems-Systems Development Overview

Degree of relationships –

One entity related to another of the same entity type

Entities of two different types related to each other

Entities of three different types related to each other

Page 46: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 46 of 46

Database systems-Systems Development Overview

Unary relationships

Page 47: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 47 of 46

Database systems-Systems Development OverviewBinary relationships

Page 48: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 48 of 46

Database systems-Systems Development Overview

Ternary relationships

Note: a relationship can have attributes of its own

Page 49: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 49 of 46

Database systems-Systems Development Overview

Quaternary relationship called Arranges

Page 50: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 50 of 46

Database systems-Systems Development Overview

50

Relationship Types

• Recursive Relationship– Relationship type where same entity type

participates more than once in different roles.

• Relationships may be given role names to indicate purpose that each participating entity type plays in a relationship.

Page 51: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 51 of 46

Database systems-Systems Development Overview

Recursive Relationships

• Relationship can exist between different occurrences of the same type of entity

Example:

EMPLOYEE manager EMPLOYEE NETWORK makes NETWORK

Em ployee

m anager

N etwork

m akes

Page 52: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 52 of 46

Database systems-Systems Development Overview

52

Recursive relationship called Supervises with role names

© Pearson Education Limited 1995, 2005

Page 53: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 53 of 46

Database systems-Systems Development Overview

Basic relationship with only maximum cardinalities

Mandatory minimum cardinalities

Page 54: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 54 of 46

Database systems-Systems Development Overview

Optional cardinalities with unary degree, one-to-one relationship

Page 55: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 55 of 46

Database systems-Systems Development Overview

A ternary relationship with attributes

Page 56: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 56 of 46

Database systems-Systems Development Overview

Representing a bill-of -materials structure

A unary relationship with an attribute. This has a many-to-many relationship

Page 57: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 57 of 46

Database systems-Systems Development Overview

Examples of multiple relationships – entities can be related to one another in more than one way

Employees and departments

Page 58: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 58 of 46

Database systems-Systems Development Overview

What is a Good Data Model?

• A good data model is simple.– Data attributes that describe any given entity should describe

only that entity.– Each attribute of an entity instance can have only one value.

• A good data model is essentially nonredundant.– Each data attribute, other than foreign keys, describes at

most one entity.– Look for the same attribute recorded more than once under

different names.

• A good data model should be flexible and adaptable to future needs.

Page 59: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 59 of 46

Database systems-Systems Development Overview

Key constraints: Examples

• Example Scenario 1: An inventory database contains information about parts and manufacturers. Each part is constructed by exactly one manufacturer.

• Example Scenario 2: A customer database contains information about customers and sales persons. Each customer has exactly one primary sales person.

• What do the ER diagrams look like?

Page 60: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 60 of 46

Database systems-Systems Development Overview

Entity Relationship Diagram Methodology

Page 61: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 61 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

7. Identify attributes

8. Map attributes

9. Draw fully attributes

10. Check results

Page 62: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 62 of 46

Database systems-Systems Development Overview

Example

A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one, but possibly more departments. At least one employee is assigned to a project, but an employee may be on vacation and not assigned to any projects. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number and a unique project number.

Page 63: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 63 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Identify roles, events, locations, tangible things or concepts about

which the end-users want to store data

Page 64: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 64 of 46

Database systems-Systems Development Overview

Example - entities

A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one, but possibly more departments. At least one employee is assigned to a project, but an employee may be on vacation and not assigned to any projects. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number and a unique project number.

Page 65: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 65 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Find natural associations betweenpairs of entities using a relationship matrix

Page 66: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 66 of 46

Database systems-Systems Development Overview

Relationship Matrix

Department Employee Supervisor Project

Department

Employee

Supervisor

Project

Page 67: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 67 of 46

Database systems-Systems Development Overview

Relationship Matrix

Department Employee Supervisor Project

Department is assigned run by

Employee belongs to works on

Supervisor runs

Project uses

Page 68: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 68 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Put entities in rectangles and relationships on line segmentsconnecting the entities

Page 69: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 69 of 46

Database systems-Systems Development Overview

ERD Components

Entity1 Entity2

Relationship

Page 70: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 70 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Put entities in rectangles and relationships on line segmentsconnecting the entities

Page 71: Erd Concepts

Department Supervisor

run by

ProjectEmployee

works on

is assigned

Page 72: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 72 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Determine the number ofoccurences of one entity fora single occurrence of the related entity

Page 73: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 73 of 46

Database systems-Systems Development Overview

Cardinality

• For each entity X and every entity Y it has a relationship with– Each X has NUMBER Y

• For example,– Each department has exactly one

supervisor

Page 74: Erd Concepts

Symbol Meaning

One and only one

One or more

Zero or more

Zero or one

Page 75: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 75 of 46

Database systems-Systems Development Overview

Sample E-R Diagram

Page 76: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 76 of 46

Database systems-Systems Development Overview

Summary of multiplicity constraints

Page 77: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 77 of 46

Database systems-Systems Development Overview

Basic E-R Notation

Entity symbols

Relationship symbols

Attribute symbols

A special entity that is also a relationship

Page 78: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 78 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Determine the number ofoccurences of one entity fora single occurrence of the related entity

Page 79: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 79 of 46

Database systems-Systems Development Overview

Cardinality "list"

• Each department has exactly one supervisor. • A supervisor is in charge of one and only one

department. • Each department is assigned at least one

employee. • Each employee works for at least one

department. • Each project has at least one employee working

on it. • An employee is assigned to 0 or more projects.

Page 80: Erd Concepts

Department Supervisor

run by

ProjectEmployee

works on

is assigned

Page 81: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 81 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Identify the data attributes thatuniquely identify one and onlyone occurrence of the relatedentity

Page 82: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 82 of 46

Database systems-Systems Development Overview

Example - primary keys

A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one, but possibly more departments. At least one employee is assigned to a project, but an employee may be on vacation and not assigned to any projects. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number and a unique project number.

Page 83: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 83 of 46

Database systems-Systems Development Overview

Attributes

Entity1 Entity2

Relationship

Attribute Primary Key

Page 84: Erd Concepts

Department Supervisor

run by

ProjectEmployee

works on

is assigned

SupervisorNumber

ProjectNumber

EmployeeNumber

DepartmentName

Page 85: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 85 of 46

Database systems-Systems Development Overview

An ERD design methodology

1. Identify entities

2. Find relationships

3. Draw rough ERD

4. Fill in cardinality

5. Define primary keys

6. Draw key-based ERD

Eliminate many-to-many relationships and includeprimary and foreign keys

Page 86: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 86 of 46

Database systems-Systems Development Overview

Many-to-many = bad

• Cannot be represented in the relational model and pose some other problems

• Solution– Replace it with an association entity – Each entity forms a relation with it

Page 87: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 87 of 46

Database systems-Systems Development Overview

Verbal Example

• Many to many– A department has one or more employees– An employee belongs to one or more

departments• Associative entity

– A department has one or more Employee-Department

– An employee has one or more Employee-Department

Page 88: Erd Concepts

Department

Employee

is assigned

Page 89: Erd Concepts

Department

Employee

is assigned

Employee-Department involves

Page 90: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 90 of 46

Database systems-Systems Development Overview

Strong vs. Weak Entities, and Identifying Relationships

• Strong entities – exist independently of other types of entities– has its own unique identifier– represented with single-line rectangle

• Weak entity– dependent on a strong entity…cannot exist on its own– Does not have a unique identifier– represented with double-line rectangle

• Identifying relationship– links strong entities to weak entities– represented with double line diamond

Page 91: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 91 of 46

Database systems-Systems Development Overview

Figure : Strong and weak entities

Strong entity Weak entityIdentifying relationship

Page 92: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 92 of 46

Database systems-Systems Development Overview

Associative Entities

• It’s an entity – it has attributes

• AND it’s a relationship – it links entities together

• When should a relationship with attributes instead be an associative entity? – All relationships for the associative entity should be many– The associative entity could have meaning independent of the other

entities– The associative entity preferably has a unique identifier, and should

also have other attributes– The associative may be participating in other relationships other

than the entities of the associated relationship– Ternary relationships should be converted to associative entities

Page 93: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 93 of 46

Database systems-Systems Development Overview

Figure : An associative entity (CERTIFICATE)

Associative entity involves a rectangle with a diamond inside.Note that the many-to-many cardinality symbols face toward the associative entity and not toward the other entities

Page 94: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 94 of 46

Database systems-Systems Development Overview

Repeating groups, normalisation

• Normalization– Eliminate redundancy– Organise data efficiently– Reduce potential for anomalies

• Normal form - "how normalised" a relational database is

• There are 6 normal forms• Text limited to 3

Page 95: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 95 of 46

Database systems-Systems Development Overview

Conclusions

• Just a small start• An important process• Get lots of practice• Ask lots of questions

Page 96: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 96 of 46

Database systems-Systems Development Overview

7. Identify Attributes

Objective: Name the information details (fields), which are essential to the

system under development

The only attributes indicated are the names ofA company has several departments.

Each department has a supervisor and at least one employee. Employees must be assigned to at least one, but possibly more departments.

At least one employee is assigned to a project, but an employee may be on vacation and not assigned to any projects.

The important data fields are the names of the departments, projects, supervisors, and employees, as well as, the supervisor numbers, employee numbers and project numbers.

Page 97: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 97 of 46

Database systems-Systems Development Overview

8. Map Attributes

Objective: For each attribute, match it with exactly one entity that it describes

Attribute Entity

Department Name Department

Employee Number Employee

Employee Name Employee

Supervisor Number Supervisor

Supervisor Name Supervisor

Project Name Project

Project Number Project

Page 98: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 98 of 46

Database systems-Systems Development Overview

9. Draw Fully Attributed ERD

Objective: Adjust the ERD from Step 6 to account for entities or relationships

discovered in Step 8.

Page 99: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 99 of 46

Database systems-Systems Development Overview

9. Draw Fully Attributed ERD

Page 100: Erd Concepts

Naveed Anwer Butt @ UOG -April 2009

Week 7: Slide 100 of 46

Database systems-Systems Development Overview

Data Dictionary Sample An example for a Banking System

Customer Transaction Account

First Name Last Name

Middle Name

NamePAN

Gender

AddressTelephone

Customer No

Transaction No Date

TType

Amount

TP Account

Account No

Account No Account Type

Customer No Balance


Recommended