Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A...

12
Software Engineering 16/12/2014 ERD diagrams 1 Lecture 16 How to draw ERD 1 A little Review Entity Relationship Diagrams a major data modelling tool and will help organize the data in your project into entities and define the relationships between the entities. 2

Transcript of Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A...

Page 1: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 1

Lecture 16How to draw ERD

1

A little Review

• Entity Relationship Diagrams

– a major data modelling tool and will help organize the data in your

project into entities and define the relationships between the entities.

2

Page 2: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 2

Components of ERD

1. Entity

2. Relationship

3. Cardinality

4. Attribute

3

Entity

• A data entity is anything real or abstract about which we want

to store data.

• Entity types fall into five classes:

roles, events, locations, tangible things or concepts.

e.g. employee, payment, campus, book.

• Specific examples of an entity are called instances. e.g. the

employee John Jones etc.

4

Page 3: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 3

Attributes

– A data attribute is a characteristic common to all or most

instances of a particular entity

– They can be used to

o Name an instance of the data object

o Describe the instance

o Make reference to another instance in another table

– Name, address, Employee Number, pay rate are all

attributes of the entity employee

5

Relationships

– It depicts the association between one or more data objects

e.g: A bookstore displays books

6

Page 4: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 4

Cardinality

• Cardinality defines

– It is the specification of the number of occurrences of one

object that can be related to the number of occurrences of

another object

o One-to-one

o One-to-many

o Many-to-many

7

Cardinality ERD notation

8

Page 5: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 5

Recursive

EMPLOYEEsupervises

is supervised by

9

Modality

• Modality

– Defines the need for the relationship to occur

o Modality = 0 Optional

o Modality = 1 Mandatory

10

Page 6: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 6

Entity Relationship Diagram(ERD)–Notation

(0, m) (1, 1)

object objectrelationship1 2

One common form:

(0, m)

(1, 1)

object1 object2

relationship

Another common form:

attribute

11

The ERD: An Example

(1,1) (1,m)placesCustomer

requestfor service

generates(1,n)

(1,1)

workorder

worktasks

materials

consistsof

lists

(1,1)(1,w)

(1,1)

(1,i)

selectedfrom

standardtask table

(1,w)

(1,1)

12

Page 7: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 7

A Simple 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.

13

A Simple 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.

14

Page 8: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 8

1. Identify Entities

o The entities in this system are

o Department

o Employee

o Supervisor

o Project

o One is tempted to make Company an entity, but it is a false

entity because it has only one instance in this problem.

o True entities must have more than one instance.

15

2. Find Relationships

We construct the following Entity Relationship Matrix:

Department Employee Supervisor Project

Department is assigned run by

Employee belongs to works on

Supervisor runs

Project uses

16

Page 9: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 9

3. Draw Rough ERD

We connect the entities whenever a relationship is shown in

the entity Relationship Matrix.

17

4. Fill in Cardinality

From the description of the problem we see that:

o Each department has exactly one supervisor.

o A supervisor is in charge of one and only one department.

o Each department is assigned at least one employee.

o Each employee works for at least one department.

o Each project has at least one employee working on it.

o An employee is assigned to 0 or more projects.

18

Page 10: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 10

Rough ERD plus Cardinality

19

5. Identify Attributes

The only attributes indicated are the names of the departments,

projects, supervisors and employees, as well as the supervisor

and employee NUMBER and a unique project number.

20

Page 11: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 11

Benefits of ERD

• ER diagrams are easy to understand and do not require

a person to undergo extensive training to be able to work

with it.

• Designers can use ER diagrams to easily communicate

with developers, customers, and end users, regardless

of their IT proficiency

• ER diagrams are readily translatable into relational

tables which can be used to quickly build databases.

• ER diagrams may be applied in other contexts such as

describing the different relationships and operations

within an organization.

21

This Lecture in Exams

• Identify the entities, attributes,

relationships, and cardinality ratios from

the description. (4 marks)

• Draw an entity-relationship diagram

showing the items you identified. (4 marks)

22

Page 12: Lecture 14 Analysis Concepts & Modeling · Relationship 3. Cardinality 4. Attribute 3 Entity • A data entity is anything real or abstract about which we want to store data. ...

Software Engineering 16/12/2014

ERD diagrams 12

Further Studies

• http://www.conceptdraw.com/solution-

park/diagramming-ERD

23