ch5: software specification. 1 descriptive specifications describe desired properties of system ...

36
Ch5: Software Specification

Post on 21-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

Ch5: Software Specification

Page 2: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

2

Descriptive specifications

Describe desired properties of system

Three types:

Page 3: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

3

ER diagrams

Used to describe a data model of the system

ER diagrams consist of between data objects

Page 4: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

4

Data Objects (Entities)

A person, place, concept, or thing which is represented in the system.

Examples: A report or display A telephone call An event (an alarm) A person An organization unit (Accounting department) A place (Warehouse) A file structure

Page 5: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

5

Entity type vs. entity instance

Entity type:

Entity instance:

Compare this with class and object in OO paradigm.

Page 6: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

6

Entities

Represented by a rectangle

Person Car

Page 7: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

7

Weak entities

A weak entity is one which cannot exist without the existence of someother entity

Example:

Page 8: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

8

Attributes

Define properties of a data objectRepresented by an oval attached to an entity

Person

Name Address Age SSN

Page 9: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

9

Attributes (contd..)

Car

Make Model ID#BodyType Color Owner

Page 10: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

10

Attributes (contd..)

Can name a data object:

Describe a data object:

Refer to another data object:

Page 11: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

11

Attributes (contd..)

Consider an entity city in a travel reservation system Can name a data object:

Describe a data object:

Refer to another data object:

Page 12: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

12

Identifier attributes

Attribute becomes “key” when we want to find an instance of the object

Example:

Keys often must be unique, but not always

Page 13: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

13

Single-valued vs. multi-valued attributes

Single-valued attribute:

Multi-valued attribute:

Identify single-valued and multi-valued attributes for the entity city.

Page 14: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

14

Notation

Employee Name

Employee Skills

Single-valued attribute

Multi-valued attribute

Page 15: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

15

Relationships

A relationship is a logical association between two types of entities.

Consider books and bookstores: Bookstore orders books Bookstore displays books Bookstore stocks books Bookstore sells books Bookstore returns books

Represented by a diamond

Page 16: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

16

Relationships: Example

Bookstore Books

Orders

Page 17: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

17

Relationships: Example

STUDENT

CLASS

ENROLLED_IN

NAME

GENDER

AGE

SUBJECT

COURSE_ID

MAX_ENROLLMENT

Page 18: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

18

Relationships: Cardinality

How many occurrences of object x are related to how many occurrences of object y.

Doesn’t indicate whether one data object must participate in the relationship.

Page 19: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

19

Relationships: Modality

Modality = 0, if relationship is optional Modality = 1, if relationship is mandatory

Page 20: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

20

Cardinality & Modality: Notation

E1 R E2(min,max) (min,max)

Modality Cardinality0 – Partial 1 – One1 – Mandatory M – More than one

Page 21: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

21

Cardinality & Modality: Notation (contd..)

Customer R Order(0,M) (1,1)

Places

A customer may place (modality 0) zero to many orders (cardinality M)An order is placed by one and only customer (modality and cardinality 1).

Page 22: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

22

Cardinality Notation

Customer Order

Places

Assume that modality is always 1, that is, the participation of objectsis mandatory

One customer places many orders.Arrow pointing towards an entity which has a single object participatingin the relationship

Page 23: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

23

Relationship cardinalities

A R B

A R B

A R B

A R B

A R B is one to one

A R B is one to many (one A, many B)

A R B is many to one (one B, many A)

A R B is many to many (many A & B)

1 1

1 m

n 1

m n

Page 24: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

24

Relationship cardinalities: Example

A R B

A R B

A R B

Parts Suppliers

Parts Suppliers

Parts Suppliers

1 n

m 1

m n

A supplier supplies many parts.A part is supplied by many suppliersParts are supplied by suppliers.

Page 25: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

25

Degree of relationships

Unary relationship:

Binary:

Ternary:

Page 26: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

26

Degree of relationships (contd..)

Unary relationship

Employee Is_Manager_Of

Assembly Part Is_Composed_Of

Page 27: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

27

Degree of relationships (contd..)

Binary relationships

Most relationships fall in this category

Faculty Course

Teaches

Manager Project

Manages

Page 28: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

28

Degree of relationships (contd..)

Ternary relationships

Relationships that exist between three entities

Vendor

Warehouse

Product

Ships

Page 29: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

29

Finding entities and relationships

Identify the system information: User interviews Paper and screen documents Previous system documentation

Identify entities: Heuristics Analysis of English grammar Entity-Relationships

Page 30: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

30

EnglishProper NounCommon NounTransitive verbIntransitive verb

AdjectiveAdverb

ERDEntity (“Name” of an entity)Entity or entity-typeM-ary relation (M>1)Unary relationship or attribute ValueAttribute of an entityAttribute of a relationship

English Grammar – Rule #1

Page 31: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

31

English Grammar Rules

Consider two sentences of the form: “There are ….. X in Y”Or “Y has …. X”

Example:There are more than 200 employees in every department.

Every department has more than 200 employees

X Y

Y X

Entities: X and Y

Page 32: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

32

English Grammar Rules

If the English sentence says, “The X of Y is Z”

Rule #1: Y is an entity

Rule #2: X is either an Attribute or an Entity depending on what type of “Z” it is.

Rule #3a: If “Z” is a proper noun, then X is a relationship between Y and Z.

Rule #3b: Otherwise, X is an attribute of Y.

Page 33: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

33

English Grammar: Rule #3 (Examples)

The birthdate of the student is 12/08/80.

Attribute(X) Entity(Y) not a proper noun (Z)

The advisor of John Smith is Dr. Greene

Relationship(X) Entity (Y) Proper Noun(Z)

The X of Y is Z

The X of Y is Z

Page 34: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

34

ER diagrams: Summary

Semi-formal notation Widely used:

Page 35: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

35

ER Diagrams: Example

Consider a course registration and student advising system. This system maintains information regarding the courses offered each semester as well as the advisors assigned to each student. Each course has a numberof students enrolled, while each student can register for a number of courses. A course is taught by a single instructor. Each instructor teachesonly one course per semester. In addition, an instructor is responsible for advising several students. Each student is assigned a single advisor. Draw an ER diagram for the course registration and student advising system.

Page 36: Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:

36

ER Diagrams: Example

Course Student

Instructor

Taught_by Advised_by

Enrolled_In