Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2....

66
Chapter 4 Chapter 4 Data Data-Oriented Models Oriented Models 1 / 66

Transcript of Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2....

Page 1: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

Chapter 4Chapter 4

DataData--Oriented ModelsOriented Models

1 / 66

DataData--Oriented ModelsOriented Models

Page 2: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

Chapter 4Data-Oriented Models

�� 4.1. Data Models: The ERD4.1. Data Models: The ERD

�� 4.2. Entity4.2. Entity--Relationship ModelingRelationship Modeling

�� 4.3. Object4.3. Object--Oriented ModelsOriented Models

4.4. An Introduction to Objects4.4. An Introduction to Objects

2 / 66

�� 4.4. An Introduction to Objects4.4. An Introduction to Objects

�� 4.5. Object4.5. Object--Oriented v.s. ObjectOriented v.s. Object--BasedBased

�� 4.6. Conceptual, Logical & Physical Models4.6. Conceptual, Logical & Physical Models

�� 4.7. Models as Communication Tools4.7. Models as Communication Tools

Page 3: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.1. Data Models: The ERD

��Research to find ways to model dataResearch to find ways to model data

��To give template for database designTo give template for database design

��Many notations were triedMany notations were tried

�Mid-1970s: Databases were just

coming into use

3 / 66

��Many notations were triedMany notations were tried

��Chen (1976) proposed theChen (1976) proposed the

EntityEntity--Relationship Diagram Relationship Diagram

(ERD)(ERD)

Page 4: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

DATADATAandand

How it is Linked and How it is Linked and

The ERD was the first systems The ERD was the first systems analysis tool to focus onanalysis tool to focus on

4 / 66

How it is Linked and How it is Linked and OrganizedOrganized..

It was from this that It was from this that objects then evolved.objects then evolved.

Page 5: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� The EntityThe Entity--Relationship Relationship Principle, Principle, andand

�� The EntityThe Entity--Relationship Relationship Notation.Notation.

��These further issues were also These further issues were also

investigated by Chen and others:investigated by Chen and others:

4.1. Data Models: The ERD

�Chen made two contributions:

5 / 66

investigated by Chen and others:investigated by Chen and others:

�� EE--R models for database designR models for database design

�� The The significancesignificance of the data of an enterpriseof the data of an enterprise

��Data as a Data as a corporate asset.corporate asset.

�� The The stabilitystability of the data of an enterpriseof the data of an enterprise

Page 6: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

The following six points all relate to both EThe following six points all relate to both E--R and Object R and Object modeling. Now let’s examine them in this order:modeling. Now let’s examine them in this order:

� � � � � � � � The EntityThe Entity--Relationship Relationship Principle.Principle.

� � � � � � � � EE--R models for database design.R models for database design.

� � � � � � � � The The stabilitystability of data. of data.

4.2. Entity-Relationship Modeling

6 / 66

� � � � � � � � The The stabilitystability of data. of data.

� � � � � � � � The The significancesignificance of data.of data.

� � � � � � � � Data as a Data as a corporate asset.corporate asset. EntityEntity--Relationship Relationship Notation.Notation.

Page 7: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Earlier methods emphasized Earlier methods emphasized what the what the users need to know users need to know to do their job.to do their job.

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

�� The EThe E--R principle focuses on the R principle focuses on the

things we need to keep datathings we need to keep data aboutabout..

7 / 66

��Here we emphasize what Here we emphasize what thingsthings the users the users

need to know need to know aboutabout..�� The word The word EntityEntity means a means a thing.thing.

�� LaterLater we worry about what items they we worry about what items they

need to know need to know aboutabout each entity.each entity.

Page 8: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

A A Data Entity Data Entity is someis somethingthing that has that has

separate and distinct existence separate and distinct existence in the in the

world of the users world of the users and is of interest to and is of interest to

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

8 / 66

world of the users world of the users and is of interest to and is of interest to

the users in that they need to keep the users in that they need to keep

data data aboutabout it in order to do their job.it in order to do their job.

Page 9: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

An An is a is a

class or category class or category

We define:We define:

Entity TypeEntity Type

9 / 66

class or category class or category

expressing the expressing the common common properties properties that allow a that allow a

number of entities to be number of entities to be

treated similarly.treated similarly.

Page 10: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��Entity types are always singular.Entity types are always singular.

��So our entity lists look like this:So our entity lists look like this:

PhonePhone

�Customer

BookingBooking

�Venue

SalesSales

�Customer

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

10 / 66

All SingularAll Singular

�Customer

�Number

�Line

�Call

�Service

�Venue

�Artist

�Agent

�Concert

�Performance

�Customer

�Seat

�Customer

�Product

�Sales clerk

Page 11: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

An individual An individual CustomerCustomer or or

ProductProduct or or SaleSale or or CallCall or or

ArtistArtist is then an is then an

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

11 / 66

ArtistArtist is then an is then an

OccurrenceOccurrenceof the Entity Type.of the Entity Type.

Page 12: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��AttributesAttributes are the are the data elements data elements

carried by an entity that describe it carried by an entity that describe it

and record its state.and record its state.

���� The EntityThe Entity--Relationship Relationship PrinciplePrinciple..

12 / 66

��AttributesAttributes are the things we need to are the things we need to

know know aboutabout an Entity.an Entity.

Page 13: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

We define:We define:

An An AssociationAssociation is the interaction is the interaction

� � � � The Entity-Relationship Principle.

Associations:

13 / 66

An An AssociationAssociation is the interaction is the interaction

of two entities and is represented of two entities and is represented

by a verb.by a verb.

Page 14: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��The purpose is to provide access The purpose is to provide access

paths to the data.paths to the data.

��When a sale occurs, we will link:When a sale occurs, we will link:

A CustomerA Customer

� � � � The Entity-Relationship Principle.

Associations :

14 / 66

A CustomerA Customer

To a ProductTo a Product

To a Sales Clerk.To a Sales Clerk.

��Using a Using a verbverb to describe each link.to describe each link.

Page 15: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

In this way we are able to diagram the In this way we are able to diagram the

structurestructure of our user’s business data,of our user’s business data,

independentindependent

� � � � The Entity-Relationship Principle.

Associations:

15 / 66

independentindependent of any way that the data of any way that the data

may be used, may be used,

either now or in the future. either now or in the future.

Page 16: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

� � � � The Entity-Relationship PrinciplePrincipleSUMMARYSUMMARY

�� An An EntityEntity is a thing the users need to know (i.e, record) is a thing the users need to know (i.e, record)

something about.something about.

�� An An Entity Type Entity Type is a group or class of entities that are is a group or class of entities that are

all the same kind of thing.all the same kind of thing.

�� An An OccurrenceOccurrence of an Entity Type is a specific of an Entity Type is a specific

individual thing of the kind the Entity Type describes.individual thing of the kind the Entity Type describes.

16 / 66

individual thing of the kind the Entity Type describes.individual thing of the kind the Entity Type describes.

�� AttributesAttributes are the things we need to know about an are the things we need to know about an

Entity.Entity.

�� An An AssociationAssociation is the interaction of two Entities and is is the interaction of two Entities and is

represented by a verb.represented by a verb.

�� These interactions among the Entities (i.e., these These interactions among the Entities (i.e., these

associationsassociations) show us the ) show us the pathwayspathways we need to follow we need to follow

through the database to access the data.through the database to access the data.

Page 17: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

���� EE--R models for database design.R models for database design.

There is a very significant reason There is a very significant reason

why Entities, Attributes and why Entities, Attributes and

Associations are so fundamentally Associations are so fundamentally

17 / 66

Associations are so fundamentally Associations are so fundamentally

important for systems important for systems

development.development.

Page 18: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

For database design:For database design:

��Each Each EntityEntity becomes a becomes a filefile or or tabletable..

AttributeAttribute

���� EE--R models for database design.R models for database design.

18 / 66

��Each Each AttributeAttribute becomes a becomes a fieldfield

(i.e., a (i.e., a columncolumn))

��Each Each AssociationAssociation becomes an becomes an

access pathway access pathway (i.e., a (i.e., a foreign keyforeign key))

Page 19: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

This tells us thatThis tells us that

Data Entities Are Stable Data Entities Are Stable

���� TheStabilityStability of Data.

19 / 66

Data Entities Are Stable Data Entities Are Stable Over Time.Over Time.

Page 20: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��However, entities are neither static nor However, entities are neither static nor

stagnant;stagnant;

��There may be an occasional new entity,There may be an occasional new entity,

��There will often be new attributes,There will often be new attributes,

���� TheStabilityStability of Data.

20 / 66

��There will often be new attributes,There will often be new attributes,

��But as long as we stay in the But as long as we stay in the

same business same business there will be very there will be very

few new entities.few new entities.

Page 21: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

This stability contributes This stability contributes

greatly to reducing the costs greatly to reducing the costs

and delays in system and delays in system

���� TheStabilityStability of Data.

21 / 66

and delays in system and delays in system

maintenance.maintenance.

Page 22: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

However, However, beware new businessbeware new business!!

Mergers, acquisitions, takeovers and Mergers, acquisitions, takeovers and diversifications diversifications can all put your can all put your

company into company into

���� TheStabilityStability of Data.

22 / 66

company into company into

new businesses new businesses

with a host of with a host of

new entity types.new entity types.

Page 23: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

���� TheSignificance of Data.

The Data modeler’s Creed:The Data modeler’s Creed:

DataData

23 / 66

DataDatais theis the

Centre of the UniverseCentre of the Universe

Page 24: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Since data is something the users Since data is something the users must must

have have in order to work,in order to work,

�� It can rightly be regarded as a It can rightly be regarded as a Business Business Asset Asset or or ResourceResource

�� Just likeJust like

� � � � Data as a CorporateCorporate Asset.

24 / 66

�� Just likeJust like

FinanceFinance

Human ResourcesHuman Resources

Plant and EquipmentPlant and Equipment

VehiclesVehicles

InventoriesInventories

Etc.Etc.

Page 25: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� AcquisitionAcquisition

� � � � Data as a CorporateCorporate Asset.

Like any corporate asset, there are some

basic functions that must be done as

part of managing the asset:

25 / 66

�� AcquisitionAcquisition

�� Organizing, storing and safekeepingOrganizing, storing and safekeeping

�� Deployment, on time, to the people who Deployment, on time, to the people who

need itneed it

�� Disposal when no longer neededDisposal when no longer needed

Page 26: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� This has led to two new functions in the This has led to two new functions in the

information industry,information industry,

Data Administration (DA) and Data Administration (DA) and

Data Resource Management (DRM).Data Resource Management (DRM).

�� DA is a middleDA is a middle--management function management function

� � � � Data as a CorporateCorporate Asset.

26 / 66

�� DA is a middleDA is a middle--management function management function

concerned with finding and documenting concerned with finding and documenting

every data element the company uses.every data element the company uses.

�� DRM is a highDRM is a high--level management function, level management function,

involving longinvolving long--term strategic planning. DRM term strategic planning. DRM

reports to the CIO reports to the CIO (Chief Information Officer; in a (Chief Information Officer; in a

wellwell--organized company the CIO is a viceorganized company the CIO is a vice--president).president).

Page 27: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��The focus of DA and DRM is to The focus of DA and DRM is to

manage data as we would manage manage data as we would manage

any other business resource.any other business resource.

��The ERD has been the tool used to The ERD has been the tool used to

� � � � Data as a CorporateCorporate Asset.

27 / 66

��The ERD has been the tool used to The ERD has been the tool used to

understand, document and understand, document and

administer data.administer data.

��As of now, the Object Model is taking As of now, the Object Model is taking

over this function.over this function.

Page 28: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

The Entity-Relationship Notation.

��There are many EThere are many E--R notations.R notations.

��All of them work, any will do the job.All of them work, any will do the job.

��Use whichever one you or your boss or Use whichever one you or your boss or

your professor or your client prefers.your professor or your client prefers.

28 / 66

your professor or your client prefers.your professor or your client prefers.

��UML is now the standard notation in UML is now the standard notation in

the object world, sothe object world, so

��We will use UML for our Entities as We will use UML for our Entities as

well as our Objects.well as our Objects.

Page 29: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Draw an Entity as a square or rectangular Draw an Entity as a square or rectangular

box, divided by a line near the top. box, divided by a line near the top.

�� Above the line place the name, singular.Above the line place the name, singular.

The Entity-Relationship Notation.Notation.

EntitiesEntities

29 / 66

Student

Page 30: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� If there are not too many, Attributes may go If there are not too many, Attributes may go

in the bottom part of the box.in the bottom part of the box.

�� Primary key first, marked with an asterisk.Primary key first, marked with an asterisk.

�� If not enough room, show only the key, If not enough room, show only the key,

The Entity-Relationship Notation.Notation.

AttributesAttributes

30 / 66

�� If not enough room, show only the key, If not enough room, show only the key,

list the others in the accompanying writelist the others in the accompanying write--up.up.

Student

*Student No.NameAgeSex

Page 31: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Draw a line joining two entity boxes to show Draw a line joining two entity boxes to show a relationship existsa relationship exists

��Write the verb above the line.Write the verb above the line.

�� Add a solid arrowhead so that it makes a Add a solid arrowhead so that it makes a sentence when you read it sentence when you read it in the direction of in the direction of

::

The Entity-Relationship Notation.

Associations:

31 / 66

sentence when you read it sentence when you read it in the direction of in the direction of the arrowthe arrow::

�� “Student “Student enrols in enrols in course”course”

Enrolls InEnrolls In

Student

*Student No.NameAgeSex

CourseOffering

*Course No.*DateRoom No.Max Enrol

Page 32: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

The Entity-Relationship Notation.

AssociationsInstructor

*Employee No.NameAgeSexSalary

teaches

College

*NameAddressPhoneRating

Employs

32 / 66

Enrols InEnrols In

CourseOffering

*Course No.*DateRoom No.Max Enrol

Student

*Student No.NameAgeSex

Page 33: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

The Entity-Relationship Notation.More Examples of Associations

Customer

*A/c No.NameAddressPhone No.Balance

Product

*Prod No.DescriptionUnit PriceQty in Stock

buys

33 / 66

Bus

*Bus No.MakeModelSeating

Driver

*Employee No.NameWageSex

Read the sentence in the direction of the arrow.Read the sentence in the direction of the arrow.

drives

“Customer buys Product”

“Driver drives Bus”

Page 34: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��The critical thing we need to know isThe critical thing we need to know is

Is it Is it OneOne, , or or

The Entity-Relationship Notation.

Multiplicity

34 / 66

Is it Is it ManyMany??

��This is the This is the MultiplicityMultiplicity of the of the

relationship (also called relationship (also called cardinalitycardinality).).

Page 35: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��We diagram this by adding a We diagram this by adding a starstar (asterisk) (asterisk)

below the relationship line whenever it below the relationship line whenever it

should show “many.” should show “many.”

�� Read this one asRead this one as

manymany

The Entity-Relationship Notation.

Multiplicity

35 / 66

“Instructor “Instructor teachesteaches manymany course offerings”course offerings”

CourseOffering

*Course No.*DateRoom No.Max Enrol

Instructor

*Employee No.NameAgeSexSalary

teaches

**

Page 36: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��We refer to this as aWe refer to this as a

“One“One--toto--Many” Association,Many” Association,

or 1:Mor 1:M

The Entity-Relationship Notation.Notation.

Multiplicity

36 / 66

or 1:Mor 1:M

CourseOffering

*Course No.*DateRoom No.Max Enrol

Instructor

*Employee No.NameAgeSexSalary

teaches

**

Page 37: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��And, since we wish And, since we wish manymany Customers to Customers to

buy buy manymany Products,Products,

��This one is a This one is a ManyMany--toto--ManyManyassociation, orassociation, or M:MM:M

The Entity-Relationship Notation.Notation.Multiplicity

37 / 66

association, orassociation, or M:MM:MCustomer

*A/c No.NameAddressPhone No.Balance

Product

*Prod No.DescriptionUnit PriceQty in Stock

buys

****

Page 38: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��There are numerous other symbols also There are numerous other symbols also

used for the “many” end of a relationship,used for the “many” end of a relationship,

�� including single and double arrows, etc.including single and double arrows, etc.

The Entity-Relationship Notation.Notation.Multiplicity

38 / 66

��The star (asterisk) is the UML standard.The star (asterisk) is the UML standard.

��Other ERD notations have their own ways Other ERD notations have their own ways

to show “many” and what direction to read to show “many” and what direction to read

the sentence.the sentence.

Page 39: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� There are many ERD notations. We are using There are many ERD notations. We are using

UML since it has become the official world UML since it has become the official world

standard object notation.standard object notation.

�� An An entityentity is a square box, with a singular name is a square box, with a singular name

The Entity-Relationship Notation.Notation.

SummarySummary

39 / 66

�� An An entityentity is a square box, with a singular name is a square box, with a singular name

above a horizontal line.above a horizontal line.

�� The The primary key primary key attribute is below the line, attribute is below the line,

with an asterisk ( with an asterisk ( * * ))�� Other attributes are listed below or on Other attributes are listed below or on

another page.another page.

ctd. . . ctd. . .

Page 40: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� An An associationassociation is a line joining two entities. is a line joining two entities.

��Write the Write the verbverb above the line, with arrowhead.above the line, with arrowhead.

�� Reading Reading in the direction of the arrowin the direction of the arrow, ,

The Entity-Relationship Notation.Notation.

SummarySummary

40 / 66

entityentity--verbverb--entity entity

should make a simple sentence.should make a simple sentence.

ctd. . . ctd. . .

Page 41: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��MultiplicityMultiplicity is is oneone (straight line) or (straight line) or manymany(asterisk) below each end of the line.(asterisk) below each end of the line.

The Entity-Relationship Notation.Notation.

SummarySummary

1:M1:M

41 / 66

1:M1:M

M:MM:M

**

** **

Page 42: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.3. Object-Oriented Models

��ObjectObject--Oriented Oriented Programming (OOP)Programming (OOP) is is now the state of the art.now the state of the art.

�� Pool of C programmers Pool of C programmers �������� C++C++

�� Everybody now learns JavaEverybody now learns Java

��ObjectObject--Oriented Oriented Analysis and Design Analysis and Design

42 / 66

��ObjectObject--Oriented Oriented Analysis and Design Analysis and Design (OOA&D) (OOA&D) are still very much the are still very much the

leading edge.leading edge.

��ObjectObject--Oriented Databases (OODBMS)Oriented Databases (OODBMS)are powerful and rapidly catching up.are powerful and rapidly catching up.

��RDBMSs are going ORDBMSs are going O--O.O.

Page 43: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��ObjectObject--Oriented Oriented Development Development Environments Environments so far are mostly so far are mostly

ObjectObject--Oriented Front Ends Oriented Front Ends that that

link to a relational database.link to a relational database.

4.3. Object-Oriented Models

43 / 66

link to a relational database.link to a relational database.

��They are truly OThey are truly O--O only in the GUI.O only in the GUI.

��They are evolving toward true OThey are evolving toward true O--O,O,

��And so are the relational databases!And so are the relational databases!

��ORACLE 9i permits OORACLE 9i permits O--O.O.

Page 44: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.4. An Introduction to Objects

��Like an entity, an object is described Like an entity, an object is described

by a noun,by a noun,

thingthing

44 / 66

��And it is And it is ““SomeSomethingthing in the user’s in the user’s

world that has a separate and distinct world that has a separate and distinct

existence, and is of interest in that existence, and is of interest in that

they need to keep data they need to keep data aboutabout it.it.””

Page 45: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��But an object is more than an entity.But an object is more than an entity.

�� In addition to the data, the object In addition to the data, the object

carries carries program code,program code,

4.4. An Introduction to Objects

45 / 66

��That That uses or changes that data.uses or changes that data.

Page 46: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

The The onlyonly way that a programway that a program

can can read or change read or change

the data carried by an object, the data carried by an object,

or or access the data access the data in any way at allin any way at all

4.4. An Introduction to Objects

46 / 66

or or access the data access the data in any way at allin any way at all

is by invoking one of the defined is by invoking one of the defined

pieces of pieces of program code program code that the object carries within itself. that the object carries within itself.

Page 47: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

This can be illustrated with a Taylor Donut This can be illustrated with a Taylor Donut

Diagram:Diagram:

4.4. An Introduction to Objects

47 / 66

CustomerCustomer

Page 48: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.4. An Introduction to Objects4.4. An Introduction to Objects

�� The “behaviors” around the outside are The “behaviors” around the outside are

subroutines or functions.subroutines or functions.

�� They physically are pieces of They physically are pieces of compiled compiled program code.program code.

�� In the real world they correspond to things In the real world they correspond to things

48 / 66

�� In the real world they correspond to things In the real world they correspond to things

this object can this object can dodo or or have done to it.have done to it.

Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 49: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.4. An Introduction to Objects4.4. An Introduction to Objects

�� These are called variously:These are called variously:

FunctionsFunctions

BehaviorsBehaviors

OperationsOperations

ServicesServices

ResponsibilitiesResponsibilities

49 / 66

Methods (esp. at the OOP level)Methods (esp. at the OOP level)

�� The data in the center is surrounded and The data in the center is surrounded and

protected by them.protected by them.Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 50: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.4. An Introduction to Objects4.4. An Introduction to Objects

�� Thus, as Coad and Yourdon put it,Thus, as Coad and Yourdon put it,

�� An object encapsulates both “the data, and An object encapsulates both “the data, and

the exclusive functions on that data.”the exclusive functions on that data.”

�� By “exclusive” we mean that By “exclusive” we mean that no other codeno other code

can access or manipulate this data.can access or manipulate this data.

50 / 66

Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 51: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� So our task as Analysts is to investigate the So our task as Analysts is to investigate the users’ business to find:users’ business to find:

The objects and their classesThe objects and their classes

Their attributes and associationsTheir attributes and associations

The operations that can be performed on, to, with or by The operations that can be performed on, to, with or by these objects.these objects.

�� Then we check how each operation will use Then we check how each operation will use or affect the data attributes.or affect the data attributes.

4.4. An Introduction to Objects

TUGASTUGAS

•• Analisa Objek dan Analisa Objek dan

51 / 66

or affect the data attributes.or affect the data attributes.

�� In the Design phase we produce In the Design phase we produce specifications for each operation.specifications for each operation.

�� In Coding we use these specifications to In Coding we use these specifications to write them as methods in whatever OOPL write them as methods in whatever OOPL we chose.we chose.

•• Analisa Objek dan Analisa Objek dan

asosiasinya dari unit bisnisasosiasinya dari unit bisnis

Yang anda interviewYang anda interview

•• Analisa menggunakan Analisa menggunakan

UML class diagramUML class diagram

•• kirim ke kirim ke

[email protected][email protected]

paling lambat 5 haripaling lambat 5 hari

Page 52: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� OOPLs and OODBMSs actually OOPLs and OODBMSs actually store the store the program code program code for the methods in the for the methods in the

database along with the data.database along with the data.

��We write small pieces of code, each to do a We write small pieces of code, each to do a

single operation.single operation.

�� A Customer object will need:A Customer object will need:

4.4. An Introduction to Objects

52 / 66

�� A Customer object will need:A Customer object will need:

An An operationoperation called UpdateAddresscalled UpdateAddress

A A piece of code piece of code to carry it outto carry it out

This code is then attachedThis code is then attached

to the object to the object

in the database.in the database.

Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 53: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��When an object is first created, it appears as When an object is first created, it appears as

a collection of fields (attributes) a collection of fields (attributes) in RAM.in RAM.

�� Some are Some are deleteddeleted after a short lifetime.after a short lifetime.

�� Some Some disappeardisappear when the machine is turned when the machine is turned

off.off.

�� These are all These are all Transient Objects, Transient Objects,

4.4. An Introduction to Objects

53 / 66

�� These are all These are all Transient Objects, Transient Objects, which which DODO NOTNOT survive beyond the survive beyond the

current session.current session. Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 54: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Some objects we need to keep around longerSome objects we need to keep around longer

CustomersCustomers

EmployeesEmployees

Products, etc.Products, etc.

�� i.e., all the things we normally would i.e., all the things we normally would

expect to put in a expect to put in a databasedatabase..

4.4. An Introduction to Objects

54 / 66

��These we create as These we create as

Persistent Objects, Persistent Objects,

thatthat DODO survive beyond survive beyond

the current session.the current session.

Change Address

PrintBalanceList all

Updat

eB

alan

ce

Chan

ge

Phone N

o

Change

Name

Cre

ate

Cu

sto

mer

Delete

Custom

er

Name Jo

Address Here

Phone No 555

Balance $1.49

CustomerCustomer

Page 55: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Objects are entities (Objects are entities (thingsthings that carry data) that carry data)

with behavior (operations) added.with behavior (operations) added.

�� These operations exclusively access the data These operations exclusively access the data

it carries it carries -- no other code can touch it.no other code can touch it.

�� Operations are coded in an OOPL or Operations are coded in an OOPL or

4.4. An Introduction to Objects

Summary

55 / 66

�� Operations are coded in an OOPL or Operations are coded in an OOPL or

OODBMS as OODBMS as methodsmethods (functions, subroutines).(functions, subroutines).

�� Code for the methods is stored Code for the methods is stored in the in the database database along with the data for the object.along with the data for the object.

�� Any program that wants data from this Any program that wants data from this

object can get it only by object can get it only by calling one of the calling one of the methods methods defined on this object.defined on this object.

Page 56: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��Transient Objects Transient Objects are created by are created by

OOPLs in the RAM of the computer andOOPLs in the RAM of the computer and

DO NOT SurviveDO NOT Survive

4.4. An Introduction to Objects

Summary

56 / 66

the current session.the current session.

��Persistent Objects Persistent Objects are stored by a are stored by a

database (OODBMS) anddatabase (OODBMS) and

DODO SurviveSurvivebeyond the current session.beyond the current session.

Page 57: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.5. Object-Oriented vs Object-Based�� Some programming languages have objects Some programming languages have objects

but do not qualify as Objectbut do not qualify as Object--Oriented.Oriented.

�� e.g. ADA 85, Clippere.g. ADA 85, Clipper

�� To be truly OTo be truly O--O, they must have two O, they must have two

important features:important features:

57 / 66

��InheritanceInheritance,, and and

��PolymorphismPolymorphism(These are defined and fully explained in Chapter 8)(These are defined and fully explained in Chapter 8)

�� These two features account for a great deal These two features account for a great deal

of the power and benefits of Oof the power and benefits of O--O methods.O methods.

Page 58: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.6. Conceptual, Logical & Physical Models

�� There are a variety of modeling paradigms There are a variety of modeling paradigms

available: DFDs, ERDs, Objects, etc.available: DFDs, ERDs, Objects, etc.

�� Each can be done at three levels.Each can be done at three levels.

�� These are three different levels of These are three different levels of

abstraction:abstraction:

58 / 66

ConceptualConceptual

LogicalLogical

PhysicalPhysical

Page 59: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

A A physical model physical model is the final is the final

design document showing how design document showing how

things will be written, done or things will be written, done or

built, and depicting all hardware built, and depicting all hardware

4.6. Conceptual, Logical & Physical Models

59 / 66

built, and depicting all hardware built, and depicting all hardware

and software platform details, and software platform details,

including data storage and data including data storage and data

transmission media.transmission media.

Page 60: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

At the At the logicallogical level, we build a model that level, we build a model that

shows everything that must be included, shows everything that must be included,

and everything that the system must do, and everything that the system must do,

withoutwithout specifying specifying how.how.

It makes no reference to choices of It makes no reference to choices of

4.6. Conceptual, Logical & Physical Models

60 / 66

It makes no reference to choices of It makes no reference to choices of hardware, software or media.hardware, software or media.

A A logical model logical model shows what a system shows what a system

must do or have, without regard for must do or have, without regard for

howhow it is to be done, built or it is to be done, built or

represented. represented.

Page 61: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

A A Conceptual Model Conceptual Model is a is a

representation of the users’ business representation of the users’ business

in terms of in terms of their conception their conception of how of how

it operates. it operates.

4.6. Conceptual, Logical & Physical Models

61 / 66

For ERDs and Object models, this For ERDs and Object models, this

means it includes M:M associations.means it includes M:M associations.

Page 62: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

��We begin by working with the users to We begin by working with the users to

produce a produce a conceptual model.conceptual model.

�� Then we expand that into a Then we expand that into a logical model logical model by adding all the features that were not by adding all the features that were not

4.6. Conceptual, Logical & Physical Models

62 / 66

by adding all the features that were not by adding all the features that were not

apparent to the users.apparent to the users.

�� Finally we make all our design decisions and Finally we make all our design decisions and

document them on thedocument them on the physical model.physical model.

Page 63: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

4.7. Models as Communication Tools

�� Users always accuse us “technoids” of Users always accuse us “technoids” of

speaking in a foreign tongue.speaking in a foreign tongue.

�� They complain that:They complain that:

�� “Those computer people never listen to us,”“Those computer people never listen to us,”

or “They never do what we were asking for”or “They never do what we were asking for”

63 / 66

�� or “They never do what we were asking for”or “They never do what we were asking for”

�� or “They gave us way more than we needed”or “They gave us way more than we needed”

�� or “They can never explain in English how to or “They can never explain in English how to

make it work.”make it work.”

Page 64: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� To build an accurate model, it is essential To build an accurate model, it is essential

that you are that you are useruser--drivendriven in your modeling.in your modeling.

�� The difference between a The difference between a goodgood systems systems

analyst and a analyst and a greatgreat one is in one is in people skillspeople skills, ,

especially especially listening skills.listening skills.

4.7. Models as Communication Tools

64 / 66

listening skills.listening skills.

�� “God gave us two ears and one mouth!”“God gave us two ears and one mouth!”

�� Remember, we are using our objectRemember, we are using our object--oriented oriented

techniques to understand techniques to understand theirtheir business.business.

Page 65: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

�� Once the users learn the notation, they Once the users learn the notation, they

quickly take to using the model to discuss quickly take to using the model to discuss

and solve problems with the analysts.and solve problems with the analysts.

4.7. Models as Communication Tools

65 / 66

�� All players on the team and sometimes All players on the team and sometimes

outside it can make use of these models.outside it can make use of these models.

Page 66: Chapter 4 · Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD 4.2. Entity4.2. Entity--Relationship Modeling Relationship Modeling 4.3. Object4.3. Object--Oriented Models Oriented

End of

66 / 66

End ofChapter 4