Top Banner
1 Structured Analysis Structured Analysis Techniques Techniques
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

1

Structured Analysis Structured Analysis TechniquesTechniques

Page 2: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

2

Entity Relationship Entity Relationship DiagramsDiagrams

Page 3: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

3

DaData ta momodeldelss

Most large software systems make use of a Most large software systems make use of a large database of information.large database of information.

An important part of system modelling is to An important part of system modelling is to define the define the logicallogical form of the data processed form of the data processed by the system.by the system.

Page 4: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

4

Entity Relationship Entity Relationship DiagramsDiagrams

Entity-Relationship diagrams are a data modeling Entity-Relationship diagrams are a data modeling technique.technique.

E-R modelling uses three basic components: entities, E-R modelling uses three basic components: entities, attributes, relationships.attributes, relationships.

EntitiesEntities An entity may be defined as:An entity may be defined as:

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

If a bank stores data about you, then to the bank If a bank stores data about you, then to the bank you are an entity.you are an entity.

If a business stores data relating to a piece of paper If a business stores data relating to a piece of paper called an invoice, then this invoice is an entity.called an invoice, then this invoice is an entity.

Page 5: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

5

Entity Relationship Entity Relationship DiagramsDiagrams

AttributesAttributes An attribute is a data element associated with an An attribute is a data element associated with an

entity. For example, the entity SUPPLIER is likely to entity. For example, the entity SUPPLIER is likely to have attributes such as supplier_name, have attributes such as supplier_name, supplier_address, supplier_phone_number and so supplier_address, supplier_phone_number and so forth.forth.

RelationshipsRelationships Entities are associated with each other via Entities are associated with each other via

relationships. A relationship is a named association relationships. A relationship is a named association between two or more between two or more entity types.entity types.

For example:For example: the relationship PLAYS-FOR between the entity types the relationship PLAYS-FOR between the entity types

PLAYER and TEAM. PLAYER and TEAM. The relationship CITIZEN-OF between the entity types The relationship CITIZEN-OF between the entity types

PERSON and COUNTRY.PERSON and COUNTRY.

Page 6: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

6

Entity Relationship Entity Relationship DiagramsDiagrams

Relationships (cont.)Relationships (cont.) Degree of Relationship. Degree of Relationship. The degree of a The degree of a

relationship may be:relationship may be: one-to-one (1:1)one-to-one (1:1) one-to-many (1:N)one-to-many (1:N) many-to-many (N:M)many-to-many (N:M)

As an example, consider a company database As an example, consider a company database which might contain the following which might contain the following relationships:relationships:

The relationship HEAD-OF between entity types MANAGER The relationship HEAD-OF between entity types MANAGER and DEPARTMENT is 1:1. This means that a department and DEPARTMENT is 1:1. This means that a department has has at most oneat most one head and that a manager is head of head and that a manager is head of at most at most oneone department.department.

Page 7: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

7

Entity Relationship Entity Relationship DiagramsDiagrams

Relationships (cont.)Relationships (cont.) Examples:Examples:

The relationship SUPERVISES between the entity The relationship SUPERVISES between the entity types MANAGER and EMPLOYEE is 1:N. This assumes types MANAGER and EMPLOYEE is 1:N. This assumes that a manager may supervise that a manager may supervise any numberany number of different of different employees but a given employee is supervised by employees but a given employee is supervised by at at most onemost one manager. manager.

The relationship ASSIGNED-TO between the entity The relationship ASSIGNED-TO between the entity types EMPLOYEE and PROJECT is N:M. Thus an types EMPLOYEE and PROJECT is N:M. Thus an employee may be assigned to employee may be assigned to manymany different projects different projects and each project may have and each project may have manymany employees assigned employees assigned to it.to it.

Page 8: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

8

NotatiNotationon

NotationNotation• The graphical representations for E-R The graphical representations for E-R

diagrams are very simple:diagrams are very simple:

A plain rectangle to represent the entity type Invoice

A labeled line to represent the relationship

Page 9: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

9

Degree of Degree of RelationshipRelationship

• There are a number of different There are a number of different graphical conventions for graphical conventions for representing the degree of each representing the degree of each relationship. The following notation relationship. The following notation will be used within these notes:will be used within these notes:

A B

A B

1:1

1:n

Page 10: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

10

ExamplExamplee

• For Example:

SUPPLIER ORDERis sent

ONE course has enrolled on it ONE or MORE students. ONE student is enrolled on ONE course.

ONE supplier is sent ONE or MORE orders.ONE order is sent to ONE supplier.

COURSE STUDENTenrols

Page 11: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

11

• For Example:

LOAN BOOKrefers to

ONE loan refers to ONE book.ONE book is referred to on ONE loan.

ExamplExamplee

Page 12: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

12

An Example:An Example:

An ER model for a small college database comprising the entity An ER model for a small college database comprising the entity types:types:

DEPARTMENT, COURSE, STUDENT and LECTURER.DEPARTMENT, COURSE, STUDENT and LECTURER.

Each department has many lecturers, one of whom is the head Each department has many lecturers, one of whom is the head

department. A lecturer belongs to only one department. Each department. A lecturer belongs to only one department. Each department department

offers many different courses, each of which is taught by a offers many different courses, each of which is taught by a single lecturer. single lecturer.

A student may enrol for many courses offered by different A student may enrol for many courses offered by different departments. departments.

Example College Example College DatabaseDatabase

Page 13: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

13

DEPARTMENT

LECTURER

STUDENT

COURSE

is_in

enrols

teaches_on

head_of

offers

ER Diagram - Small College ( solution )

Example College Example College DatabaseDatabase

Page 14: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

14

Example Local Education Example Local Education AuthorityAuthority

Another Example:Another Example:A local education authority (LEA) requires a system to A local education authority (LEA) requires a system to

hold details of thehold details of the

applicants who apply for courses run by local colleges. applicants who apply for courses run by local colleges. Each course isEach course is

run at only one college, though more than one course is run at only one college, though more than one course is run at eachrun at each

college. An applicant may apply for several courses. college. An applicant may apply for several courses. Details are to beDetails are to be

kept of the standard qualifications that the majority of kept of the standard qualifications that the majority of applicants have.applicants have.

Page 15: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

15

APPLICANT

QUALIFICATIONS COLLEGE

COURSE

has

applies_for

is_run_by

Example Local Education Example Local Education AuthorityAuthority

Page 16: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

16

Many to Many Many to Many relationshiprelationship

Decomposing a Many-to-Many (N:M) RelationshipDecomposing a Many-to-Many (N:M) Relationship Occasionally a Occasionally a many-to-manymany-to-many relationship will occur, relationship will occur,

relational databases relational databases cannotcannot accommodate this accommodate this relationship type, as such they must be removed. relationship type, as such they must be removed.

The situation is easily resolved because it is always The situation is easily resolved because it is always possible to replace a many-to-many relationship possible to replace a many-to-many relationship type with two type with two one-to-manyone-to-many types, by introducing an types, by introducing an extra entity type into the diagram.extra entity type into the diagram.

This This 'new''new' entity type may simply be the invention of entity type may simply be the invention of the systems analyst, invented for the sole purpose the systems analyst, invented for the sole purpose of eliminating the many-to-many relationship type. of eliminating the many-to-many relationship type. In other cases, some actual, physical entity might In other cases, some actual, physical entity might exist which will provide the needed linkage.exist which will provide the needed linkage.

Page 17: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

17

Imagine a business which buys in a number of parts from Imagine a business which buys in a number of parts from its suppliers. Suppose investigation and analysis has its suppliers. Suppose investigation and analysis has shown that:shown that: any one supplier might supply more than one kind of any one supplier might supply more than one kind of

part.part. any one kind of part might be bought in from a number any one kind of part might be bought in from a number

of different suppliers.of different suppliers.

SUPPLIER PARTsupplies

Many to Many Many to Many relationshiprelationship

Page 18: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

18

The many-to-many relationship type is removed as The many-to-many relationship type is removed as follows:follows:

Thinking of an appropriate Thinking of an appropriate namename for 'entity X' can be for 'entity X' can be difficult. In such cases it is acceptable to form it from difficult. In such cases it is acceptable to form it from the names of the original two entities.the names of the original two entities.

Naming the two new Naming the two new relationshipsrelationships formed by the formed by the decomposition can pose a problem however, it is decomposition can pose a problem however, it is acceptable to leave the relationships blank acceptable to leave the relationships blank providingproviding this does not impair the clarity of the diagram.this does not impair the clarity of the diagram.

SUPPLIER PART

X

Many to Many Many to Many relationshiprelationship

Page 19: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

19

Remember this?Remember this?

DEPARTMENT

LECTURER

STUDENT

COURSE

is_in

enrols

teaches_on

head_of

offers

Many to Many Many to Many relationshiprelationship

Page 20: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

20

The n:m relationship is now removed.The n:m relationship is now removed.

DEPARTMENT

LECTURER

STUDENT

COURSE

is_in

receives

teaches_on

head_of

offers

ENROLMENT

performs

Many to Many Many to Many relationshiprelationship

Page 21: 1 Structured Analysis Techniques. 2 Entity Relationship Diagrams.

21

Guidelines for Drawing an Entity-Relationship Guidelines for Drawing an Entity-Relationship Diagram:Diagram: Select likely entities.Select likely entities. Select an identifier for each of the entities.Select an identifier for each of the entities. Identify relationships between the selected Identify relationships between the selected

entities.entities. Sketch an E-R diagram, adding the degree of Sketch an E-R diagram, adding the degree of

each relationship.each relationship. Decompose any N:M relationships, allocating Decompose any N:M relationships, allocating

an identifier to any new entities formed.an identifier to any new entities formed.

GuidelinGuidelineses