Upload
lawrence-norton
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
1Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
An Introduction toAn Introduction to
Object-Oriented Object-Oriented AnalysisAnalysis
Objects and UML in plain English.Objects and UML in plain English.
Chapter 4: Data-Oriented Models.Chapter 4: Data-Oriented Models.
Based on the book by Based on the book by
David William BrownDavid William Brown
John Wiley & Sons, ISBN 0471371378
2Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
CopyrightCopyrightCopyright Copyright 88 2002 Flying Kiwi Productions2002 Flying Kiwi Productions
All rights reserved.All rights reserved.
This slide presentation is based on “An Introduction to Object-This slide presentation is based on “An Introduction to Object-Oriented Analysis; Objects and UML in Plain English,” by Oriented Analysis; Objects and UML in Plain English,” by David William Brown, Wiley, ISBN 0471371378, “The Book.”David William Brown, Wiley, ISBN 0471371378, “The Book.”
PermissionPermission is hereby granted to copy, modify or excerpt all or is hereby granted to copy, modify or excerpt all or any part of this slide presentation, provided it is solely for any part of this slide presentation, provided it is solely for use with courses, seminars or other presentations or use with courses, seminars or other presentations or productions productions where a copy of The Book is purchasedwhere a copy of The Book is purchased by or for each and by or for each and every participant or recipient.every participant or recipient.
AnAn instructor guide is available from the publisher for such instructor guide is available from the publisher for such presentations.presentations.
3Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Chapter 4 Data-Oriented Models 4.1. Data Models: The ERD4.1. Data Models: The ERD 4.2. Paradigm Shift4.2. Paradigm Shift 4.3. Entity-Relationship Modeling4.3. Entity-Relationship Modeling 4.4. Object-Oriented Models4.4. Object-Oriented Models 4.5. An Introduction to Objects4.5. An Introduction to Objects 4.6. Object-Oriented vs Object-Based4.6. Object-Oriented vs Object-Based 4.7. Conceptual, Logical & Physical 4.7. Conceptual, Logical & Physical
ModelsModels 4.8. Models as Communication Tools4.8. Models as Communication Tools
4Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 Chen (1976) proposed theChen (1976) proposed the
Entity-Relationship Diagram Entity-Relationship Diagram (ERD)(ERD)
Mid-1970s: Databases were just coming into use
5Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
DATADATA andand
How it is Linked and How it is Linked and OrganizedOrganized..
It was from this that objects It was from this that objects then evolved.then evolved.
The ERD was the first systems The ERD was the first systems analysis tool to focus onanalysis tool to focus on
6Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship The Entity-Relationship Principle, Principle, andand
The Entity-Relationship The Entity-Relationship Notation.Notation.
These further issues were also These further issues were also investigated by Chen and others:investigated by Chen and others: E-R models for database designE-R models for database design The The significancesignificance of the data of an enterprise of 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
4.1. Data Models: The ERD
Chen made two contributions:
7Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.2. Paradigm Shift
A A paradigm shift paradigm shift is a major change in the way we is a major change in the way we think about something.think about something.
True paradigm shifts are rare.True paradigm shifts are rare.
(Brooks, 1976)(Brooks, 1976)
8Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.2. Paradigm Shift
Chemistry:Chemistry: Alchemy Alchemy Atoms. Atoms. Astronomy: Astronomy: “Bible” “Bible” Galileo. Galileo.
““Bible” = Geocentric, as interpreted by InquisitionBible” = Geocentric, as interpreted by Inquisition
Biology:Biology: Creation Creation Darwin. Darwin.
Each of these was a major Each of these was a major change in how we viewed change in how we viewed
our world.our world.
Physics: Newton Einstein.
9Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.2. Paradigm Shift
a a patternpattern or mode of or mode of thinking and believingthinking and believing
that serves to organizethat serves to organize
the way we approachthe way we approach
knowledge, learning and understanding.knowledge, learning and understanding.
A A paradigm shift paradigm shift occursoccurs
when we adoptwhen we adopt
a a radically different way radically different way of organizingof organizing
all or part of our worldview.all or part of our worldview.
A paradigmparadigm is
10Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
While Objects are an evolution While Objects are an evolution from Entities, the change is so from Entities, the change is so dramatic and far-reaching. . . dramatic and far-reaching. . .
that it also qualifies as a true that it also qualifies as a true
paradigm shift.paradigm shift.
4.2. Paradigm Shift
The change to data-oriented The change to data-oriented analysis analysis methods methods CC i.e., to i.e., to ERDs ERDs CC was a was a true paradigm true paradigm shift.shift.
11Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.3. Entity-Relationship Modeling
As we saw earlier, Chen made As we saw earlier, Chen made two main contributions, the two main contributions, the
ERD Principle ERD Principle and and
ERD Notation, ERD Notation, as well as as well as investigating several other investigating several other
issues.issues.
12Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The following six points all relate to both E-R and Object The following six points all relate to both E-R and Object modeling. Now let’s examine them in this order:modeling. Now let’s examine them in this order:
The Entity-Relationship The Entity-Relationship Principle.Principle.
E-R models for database design.E-R models for database design.
The The stabilitystability of data. of data.
The The significancesignificance of data. of data.
Data as a Data as a corporate asset.corporate asset.Entity-Relationship Entity-Relationship Notation.Notation.
13Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
SalesSalesCustomersProductsSalesSales clerks
To manage a To manage a sales operation, sales operation, we we need to keep data need to keep data
about :about :
14Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
PhonePhoneCustomersNumbersLinesCallsServices
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
To run a To run a phone company, phone company, we would we would need to keep data about:need to keep data about:
15Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..To run a booking agency booking agency we must record information about:BookingBooking
VenuesVenuesArtistsArtistsAgentsAgentsConcertsConcertsPerformancePerformance
ssCustomersCustomersSeatsSeats
16Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
BookingBookingVenuesArtistsAgentsConcertsPerformance
sCustomersSeats
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..To run a booking agency booking agency we must record information about:
Notice there is noNotice there is no DateDate in this list.in this list.
Why Not?Why Not?
17Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A date can describe many A date can describe many thingsthings The key word here is The key word here is
ThingsThings
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
A A datedate is data that describes a is data that describes a ConcertConcert
18Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Each of these lists is aEach of these lists is a list of list of thingsthings
PhonePhoneCustomersCustomersNumbersNumbersLinesLinesCallsCallsServicesServices
BookingBookingVenuesVenuesArtistsArtistsAgentsAgentsConcertsConcertsPerformancesPerformancesCustomersCustomersSeatsSeats
SalesSalesCustomersCustomersProductsProductsSales clerksSales clerks
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
19Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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.
Here we emphasize what Here we emphasize what thingsthings the the
users need to know users 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.
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
The E-R principle focuses on the The E-R principle focuses on the things we need to keep datathings we need to keep data aboutabout..
20Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
You can see it is something we You can see it is something we need to know about (i.e., keep need to know about (i.e., keep data about) to do our jobdata about) to do our job
So we define it. . .So we define it. . .
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
Webster: An entity is Webster: An entity is “something “something that has separate that has separate and distinct and distinct existence”existence”
21Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A A Data Entity Data Entity is someis somethingthing that has that has separate and distinct existence separate and distinct existence in in the world of the users the world of the users and is of and is of interest to the users in that they interest to the users in that they need to keep data need to keep data aboutabout it in order it in order to do their job.to do their job.
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
22Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
So these are the So these are the entity lists entity lists for these businesses:for these businesses:
PhonePhoneCustomersCustomersNumbersNumbersLinesLinesCallsCallsServicesServices
BookingBookingVenuesVenuesArtistsArtistsAgentsAgentsConcertsConcertsPerformancesPerformancesCustomersCustomersSeatsSeats
SalesSalesCustomersCustomersProductsProductsSales clerksSales clerks
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
23Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
What we need to talk about What we need to talk about mostly is the class of all mostly is the class of all Customers, or in other words the Customers, or in other words the typetype of thing called a Customer. of thing called a Customer.
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
Grammatically, the term Entity Grammatically, the term Entity refers to a refers to a single specific single specific
CustomerCustomer or or ProductProduct or or SaleSale or or CallCall or or ArtistArtist..
24Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
An An is a is a 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.
So we define:So we define:
Entity TypeEntity Type
25Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Entity types are always singular.Entity types are always singular. So our entity lists look like this:So our entity lists look like this:
All SingularAll Singular
PhonePhoneCustomerNumberLineCallService
BookingBookingVenueArtistAgentConcertPerformanceCustomerSeat
SalesSalesCustomerProductSales clerk
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
26Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
An individual An individual CustomerCustomer or or ProductProduct or or SaleSale or or CallCall or or ArtistArtist
is then an is then an OccurrenceOccurrenceof the Entity Type.of the Entity Type.
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
27Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
I am an occurrence of the entity type I am an occurrence of the entity type “Employee”“Employee”
You are an occurrence of the entity You are an occurrence of the entity type “Student”type “Student”
We each live in an occurrence of the We each live in an occurrence of the entity type “Dwelling”entity type “Dwelling”
The last time you caught an occurrence of The last time you caught an occurrence of the entity type “Bus,” it followed an the entity type “Bus,” it followed an occurrence of the entity type “Route” while occurrence of the entity type “Route” while executing an occurrence of the entity type executing an occurrence of the entity type “Trip.”“Trip.”
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
28Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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.
AttributesAttributes are the things we need are the things we need
to know to know aboutabout an Entity.an Entity.
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
29Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
So how did the So how did the CountryCountry occurrence occurrence CanadaCanada happen to happen to get the string value get the string value “Canada” “Canada”
as the value for its as the value for its NameName attribute?attribute?
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
30Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
On the day of Canada’s confederation, the On the day of Canada’s confederation, the Founding Fathers placed 26 slips of paper Founding Fathers placed 26 slips of paper in a hat with the 26 letters of the in a hat with the 26 letters of the alphabet on them. “Just draw 3 letters,” alphabet on them. “Just draw 3 letters,” they said, “We want a short, crisp name they said, “We want a short, crisp name for our beautiful new country.” So the for our beautiful new country.” So the one with the hat did as directed, and one with the hat did as directed, and announced:announced:
““C, C, eheh??””
““N, N, eheh??””
““D, D, eheh??” ”
The Entity-Relationship The Entity-Relationship PrinciplePrinciple..
31Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Principle.
Associations:
So we have: So we have: Hundreds of Hundreds of CustomersCustomers
Thousands of Thousands of ProductsProducts
Dozens of Dozens of Sales ClerksSales Clerks
Do we have a business?Do we have a business?
NOT YET!NOT YET!
32Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Not until:Not until: A Customer A Customer buysbuys a Product a Product
A Sales Clerk A Sales Clerk sellssells a Product a Product
A Sales Clerk A Sales Clerk sellssells to a Customer to a Customer
These are the interThese are the interactionsactions
that occur between entities.that occur between entities.
Note each involves a Note each involves a verb.verb.
The Entity-Relationship Principle.
Associations:
33Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
We define:We define:
An An AssociationAssociation is the is the interaction of two entities and interaction of two entities and
is represented by a verb.is represented by a verb.
The Entity-Relationship Principle.
Associations:
34Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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
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.
The Entity-Relationship Principle.
Associations :
35Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Note we have not made any Note we have not made any mention of inputs or outputs,mention of inputs or outputs,
And we have touched on business And we have touched on business processes, but processes, but
only as they concern the data.only as they concern the data.
The Entity-Relationship Principle.
Associations:
36Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
In this way we are able to diagram In this way we are able to diagram the the structurestructure of our user’s business of our user’s business
data,data,
independentindependent of any way that the of any way that the data may be used, data may be used,
either now or in the future. either now or in the future.
The Entity-Relationship Principle.
Associations:
37Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship PrinciplePrincipleSUMMARYSUMMARY
An An EntityEntity is a thing the users need to know (i.e, is a thing the users need to know (i.e, record) something about.record) 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 individual thing of the kind the Entity Type describes.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 the interaction of two Entities and is represented by a verb.is 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 we need to follow through the database to access the data.follow through the database to access the data.
38Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
E-R models for database design.E-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 Associations are so fundamentally important for fundamentally important for
systems development.systems development.
39Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
To start with, the search for data To start with, the search for data modeling methods was for modeling methods was for databasedatabase design. design.
Many notations were developed Many notations were developed and some actually tried out.and some actually tried out.
Chen’s Chen’s ERDERD turned out best and turned out best and took over.took over.
It also caught on as a tool for It also caught on as a tool for systemssystems analysis, analysis, as well as for as well as for data analysis.data analysis.
E-R models for database design.E-R models for database design.
40Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
For database design:For database design:
Each Each EntityEntity becomes a becomes a filefile or or tabletable..
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 foreign
keykey))
E-R models for database design.E-R models for database design.
41Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The StabilityStability of Data.
This year, our favorite Transit Company is This year, our favorite Transit Company is concerned with entity types: concerned with entity types:
Bus, Driver, Route, Trip, Bus Stop and Passenger.Bus, Driver, Route, Trip, Bus Stop and Passenger.
TenTen years from now, there will be many years from now, there will be many changes in how the company is run, and in how changes in how the company is run, and in how the people do their jobs.the people do their jobs.
ButBut they will they will stillstill have to deal with have to deal with
Buses, Drivers, Routes, Trips, Bus Stops and PassengersBuses, Drivers, Routes, Trips, Bus Stops and Passengers!! Not only that, but ten years ago they worked Not only that, but ten years ago they worked
with with
Buses, Drivers, Routes, Trips, Bus Stops and PassengersBuses, Drivers, Routes, Trips, Bus Stops and Passengers!!
42Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
And a college registration system must And a college registration system must deal with entity types deal with entity types
Student, Course, Subject Area, Room, Student, Course, Subject Area, Room, Instructor and EnrolmentInstructor and Enrolment
now, now,
in the future,in the future,
and in the past,and in the past,
““As it was in the beginning, is now, As it was in the beginning, is now, and forever shall be, data without and forever shall be, data without
end. . .”end. . .”
The StabilityStability of Data.
43Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
This tells us thatThis tells us that
Data Entities Are Stable Data Entities Are Stable Over Time.Over Time.
The StabilityStability of Data.
44Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
When we organize our data around When we organize our data around the entities from the real world of the entities from the real world of the user,the user,
Those entities are stable.Those entities are stable.
The StabilityStability of Data.
45Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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,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.
The StabilityStability of Data.
46Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
This stability contributes This stability contributes greatly to reducing the greatly to reducing the
costs and delays in system costs and delays in system maintenance.maintenance.
The StabilityStability of Data.
47Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
However, However, beware new beware new businessbusiness!!
Mergers, acquisitions, takeovers and Mergers, acquisitions, takeovers and diversifications diversifications can all put your can all put your
company into company into
new businesses new businesses with a host of with a host of
new entity types.new entity types.
The StabilityStability of Data.
48Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Significance of Data.
The Data modeler’s Creed:The Data modeler’s Creed:
DataDatais theis the
Centre of the UniverseCentre of the Universe
49Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Out of the universe of all dataOut of the universe of all data Our project is concerned only with Our project is concerned only with
the subsetthe subset that belongs in the business area that belongs in the business area
we are studying.we are studying. The ERD is the tool we have been The ERD is the tool we have been
using to study, document and using to study, document and understand this data.understand this data.
The Significance of Data.
50Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The structure of this data drives the The structure of this data drives the design of the databases that must design of the databases that must store it.store it.
The databases in turn support the The databases in turn support the design of the programs,design of the programs,
That support the users’ operation by That support the users’ operation by supplying exactly the data need, when supplying exactly the data need, when they need it, in a form they can use,they need it, in a form they can use,
And by accepting the data they And by accepting the data they generate as they do their jobs.generate as they do their jobs.
The Significance of Data.
51Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
All of this must be done in a All of this must be done in a transparent, user-friendly way, transparent, user-friendly way,
So that the software enhances the So that the software enhances the
users’ users’ performance.performance.
This, after all, is the only This, after all, is the only reason why the software reason why the software
should exist at allshould exist at all!!
The Significance of Data.
52Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Data as a CorporateCorporate Asset.
Since the users both need Since the users both need and generate data as they and generate data as they work, it can be said that work, it can be said that
their operation rests upon their operation rests upon this this
pool of datapool of datathat must exist for them to that must exist for them to
function. function.
53Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Since data is something the users Since data is something the users must have must have in order to work,in order to work,
It can rightly be regarded as a It can rightly be regarded as a Business Asset Business Asset or or ResourceResource
Just likeJust likeFinanceFinanceHuman ResourcesHuman ResourcesPlant and EquipmentPlant and EquipmentVehiclesVehiclesInventoriesInventoriesEtc.Etc.
Data as a CorporateCorporate Asset.
54Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
AcquisitionAcquisition Organizing, storing and safekeepingOrganizing, storing and safekeeping Deployment, on time, to the people Deployment, on time, to the people
who need itwho need it Disposal when no longer neededDisposal when no longer needed
Data as a CorporateCorporate Asset.
Like any corporate asset, there are some basic functions that must be
done as part of managing the asset:
55Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 middle-management function DA is a middle-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 high-level management function, DRM is a high-level management function, involving long-term strategic planning. DRM involving long-term strategic planning. DRM reports to the CIO reports to the CIO (Chief Information Officer; in a (Chief Information Officer; in a well-organized company the CIO is a vice-president).well-organized company the CIO is a vice-president).
Data as a CorporateCorporate Asset.
56Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The focus of DA and DRM is to The focus of DA and DRM is to manage data as we would manage data as we would manage any other business manage any other business resource.resource.
Hitherto, the ERD has been the Hitherto, the ERD has been the tool used to understand, tool used to understand, document and administer data.document and administer data.
As of now, the Object Model is As of now, the Object Model is taking over this function.taking over this function.
Data as a CorporateCorporate Asset.
57Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Notation.
There are many E-R notations.There are many E-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.
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 well We will use UML for our Entities as well as our Objects.as our Objects.
58Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Draw an Entity as a square or Draw an Entity as a square or rectangular box, divided by a line near rectangular box, divided by a line near the top. the top.
Above the line place the name, singular.Above the line place the name, singular.
The Entity-Relationship Notation.Notation.
EntitiesEntities
Student
59Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
If there are not too many, Attributes may go in the If there are not too many, Attributes may go in the bottom part of the box.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,
list the others in the accompanying write-up.list the others in the accompanying write-up.
The Entity-Relationship Notation.Notation.
AttributesAttributes
Student
*Student No.NameAgeSex
60Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Draw a line joining two entity boxes to show a relationship existsDraw a line joining two entity boxes to show a relationship exists Write the verb above the line.Write the verb above the line.
Enrolls InEnrolls In
The Entity-Relationship Notation.
Associations:
Student
*Student No.NameAgeSex
CourseOffering
*Course No.*DateRoom No.Max Enrol
61Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Notation.
Associations
CourseOffering
*Course No.*DateRoom No.Max Enrol
Add a solid arrowhead so that it makes a sentence when you read Add a solid arrowhead so that it makes a sentence when you read it it in the direction of the arrowin the direction of the arrow::
““Student Student enrols in enrols in course”course”
Enrolls InEnrolls In
Student
*Student No.NameAgeSex
62Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Notation.
Associations
CourseOffering
*Course No.*DateRoom No.Max Enrol
Student
*Student No.NameAgeSex
Instructor
*Employee No.NameAgeSexSalary
teaches
Enrolls In
63Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Enrols InEnrols In
The Entity-Relationship Notation.
Associations
CourseOffering
*Course No.*DateRoom No.Max Enrol
Student
*Student No.NameAgeSex
Instructor
*Employee No.NameAgeSexSalary
teaches
College
*NameAddressPhoneRating
Employs
64Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Notation.More Examples of Associations
Customer
*A/c No.NameAddressPhone No.Balance
Product
*Prod No.DescriptionUnit PriceQty in Stock
buys
Read the sentence in the direction of the arrow:
““Customer buys Product.”Customer buys Product.”
65Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The Entity-Relationship Notation.More Examples of Associations
Bus
*Bus No.MakeModelSeating
Driver*Employee No.NameWageSex
Customer
*A/c No.NameAddressPhone No.Balance
Product
*Prod No.DescriptionUnit PriceQty in Stock
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”
buys
66Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Q. When a driver Q. When a driver drivesdrives a bus, a bus, how many how many does she drive?does she drive?
A. A. OneOne, usually. But over time?, usually. But over time?
Why, a whole bunch!Why, a whole bunch!Q. When a Customer Q. When a Customer buysbuys a Product, a Product, how how
many many does he buy?does he buy?
A. One per transaction, perhaps, but over A. One per transaction, perhaps, but over time we hope he’ll buy time we hope he’ll buy a great many.a great many.
The Entity-Relationship Notation.
MultiplicityMultiplicity
67Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The critical thing we need to know The critical thing we need to know isis
Is it Is it OneOne, , or or
Is it Is it ManyMany??
This is the This is the MultiplicityMultiplicity of the of the relationship (also called relationship (also called cardinalitycardinality).).
The Entity-Relationship Notation. Multiplicity
68Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Webster defines Webster defines CardinalityCardinality as “The as “The number of members in a set.”number of members in a set.”
For us, For us, MultiplicityMultiplicity is the is the number of number of occurrences occurrences of each entity type of each entity type that can be involved in an that can be involved in an association.association.
The Entity-Relationship Notation. Multiplicity
69Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
We diagram this by adding a We diagram this by adding a starstar (asterisk) below the (asterisk) below the relationship line whenever it should show “many.” relationship line whenever it should show “many.”
Read this one asRead this one as
““Instructor Instructor teachesteaches manymany course offerings”course offerings”
The Entity-Relationship Notation. Multiplicity
CourseOffering
*Course No.*DateRoom No.Max Enrol
Instructor
*Employee No.NameAgeSexSalary
teaches
**
70Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
We refer to this as aWe refer to this as a
““One-to-Many” Association,One-to-Many” Association,
or 1:Mor 1:M
The Entity-Relationship Notation.Notation. Multiplicity
CourseOffering
*Course No.*DateRoom No.Max Enrol
Instructor
*Employee No.NameAgeSexSalary
teaches
**
71Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Read the sentence in the direction of Read the sentence in the direction of the arrowthe arrow
Read the star (asterisk) as the word Read the star (asterisk) as the word
““manymany.”.”
The Entity-Relationship Notation.Notation. Multiplicity
CourseOffering
*Course No.*DateRoom No.Max Enrol
Instructor
*Employee No.NameAgeSexSalary
teaches
**
72Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 Many-to-ManyMany-to-Many association, orassociation, or M:MM:M
The Entity-Relationship Notation.Notation. Multiplicity
Customer
*A/c No.NameAddressPhone No.Balance
Product
*Prod No.DescriptionUnit PriceQty in Stock
buys
****
73Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 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 to show “many” and what direction to read the sentence.read the sentence.
The Entity-Relationship Notation.Notation. Multiplicity
74Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
There are many ERD notations. We are using UML There are many ERD notations. We are using UML since it has become the official world standard since it has become the official world standard object notation.object notation.
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, with an attribute is below the line, with an asterisk ( asterisk ( * * ))
Other attributes are listed below or on another Other attributes are listed below or on another page.page.
ctd. . . ctd. . .
The Entity-Relationship Notation.Notation.
SummarySummary
75Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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, ,
entity-verb-entity entity-verb-entity
should make a simple sentence.should make a simple sentence.
ctd. . . ctd. . .
The Entity-Relationship Notation.Notation.
SummarySummary
76Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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
M:MM:M**
** **
77Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
There is one major There is one major side benefit side benefit
to both ERDs and to both ERDs and Object modeling.Object modeling.
78Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Both serve these four important functions:Both serve these four important functions:
Allow us to Allow us to understandunderstand the users’ business the users’ business quickly and accuratelyquickly and accurately
DocumentDocument the information needs of the users’ the information needs of the users’ businessbusiness
Give the DA the tool to Give the DA the tool to understandunderstand, , documentdocument
and ultimately and ultimately controlcontrol the datathe data Give a Give a templatetemplate or or patternpattern for database design. for database design.
AndAnd they are they are more effective, more effective, and give us and give us better better insights and understanding, insights and understanding, than any of the than any of the
earlier methods.earlier methods.
79Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.4. Object-Oriented Models
Object-Oriented Object-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
Object-Oriented Object-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.
Object-Oriented Databases (OODBMS)Object-Oriented Databases (OODBMS) are are powerful and rapidly catching up.powerful and rapidly catching up.
RDBMSs are going O-O.RDBMSs are going O-O.
80Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Object-Oriented Object-Oriented Development Development Environments Environments so far are mostly so far are mostly Object-Oriented Front Ends Object-Oriented Front Ends that link that link to a relational database.to a relational database.
They are truly O-O only in the GUI.They are truly O-O only in the GUI. They are evolving toward true O-O,They are evolving toward true O-O, And so are the relational databases!And so are the relational databases!
ORACLE 9i permits O-O.ORACLE 9i permits O-O.
4.4. Object-Oriented Models
81Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.5. An Introduction to Objects
Like an entity, an object is Like an entity, an object is described by a noun,described by a noun,
And it is And it is ““SomeSomethingthing in the in the user’s world that has a separate user’s world that has a separate and distinct existence, and is of and distinct existence, and is of interest in that they need to keep interest in that they need to keep
data data aboutabout it.it.””
82Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
But an object is more than an But an object is more than an entity.entity.
In addition to the data, the object In addition to the data, the object carries carries program code,program code,
That That uses or changes that data.uses or changes that data.
4.5. An Introduction to Objects
83Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Now here is the Now here is the
fundamental principlefundamental principle
ofof Objects:Objects:
84Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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
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 that the object carries within
itself. itself.
4.5. An Introduction to Objects
85Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
I’ll say that again. . . I’ll say that again. . .
4.5. An Introduction to Objects
86Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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
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 that the object carries within
itself. itself.
4.5. An Introduction to Objects
87Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
This can be illustrated with a Taylor Donut This can be illustrated with a Taylor Donut Diagram:Diagram:
4.5. An Introduction to Objects
Change Address
PrintBalanceList all
Upd
ate
Bal
ance
Change
Phone N
o
Change
NameC
reat
eC
usto
mer
Delete
Customer
Name Jo Address Here Phone No 555 Balance $1.49
CustomerCustomer
88Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.5. An Introduction to Objects4.5. 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 In the real world they correspond to things this object can things this object can dodo or or have done to it.have done to it.
89Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.5. An Introduction to Objects4.5. An Introduction to Objects
These are called variously:These are called variously:FunctionsFunctionsBehaviorsBehaviorsOperationsOperationsServicesServicesResponsibilitiesResponsibilitiesMethods (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.
90Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.5. An Introduction to Objects4.5. An Introduction to Objects
Thus, as Coad and Yourdon put it,Thus, as Coad and Yourdon put it, An object encapsulates both “the data, An object encapsulates both “the data,
and the exclusive functions on that and the exclusive functions on that data.”data.”
By “exclusive” we mean that By “exclusive” we mean that no other no other codecode can access or manipulate this data. can access or manipulate this data.
91Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
So our task as Analysts is to investigate So our task as Analysts is to investigate the users’ business to find:the 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.
In the Design phase we produce specs for In the Design phase we produce specs for each operation.each operation.
In Coding we use these specs to write them In Coding we use these specs to write them as methods in whatever OOPL we chose.as methods in whatever OOPL we chose.
4.5. An Introduction to Objects
92Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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:An An operationoperation called UpdateAddress called UpdateAddressA 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.
4.5. An Introduction to Objects
93Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
When an object is first created, it When an object is first created, it appears as a collection of fields appears as a collection of fields (attributes) (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 when the machine is
turned off.turned off.
These are all These are all Transient Objects, Transient Objects, which which DODO NOTNOT survive beyond the survive beyond the current session.current session.
4.5. An Introduction to Objects
94Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Some objects we need to keep around longerSome objects we need to keep around longerCustomersCustomersEmployeesEmployeesProducts, 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..
These we create as These we create as
Persistent Objects, Persistent Objects,
thatthat DODO survive beyond survive beyond
the current session.the current session.
4.5. An Introduction to Objects
95Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 These operations exclusively access the data it carries - no other code can touch it.data it carries - no other code can touch it.
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 database in the 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.
4.5. An Introduction to Objects
Summary
96Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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
the current session.the current session.
Persistent Objects Persistent Objects are stored by a are stored by a database (OODBMS) anddatabase (OODBMS) and
DODO SurviveSurvive beyond the current session.beyond the current session.
4.5. An Introduction to Objects
Summary
97Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.6. Object-Oriented vs Object-Based Some programming languages have objects Some programming languages have objects
but do not qualify as Object-Oriented.but do not qualify as Object-Oriented. e.g. ADA 85, Clippere.g. ADA 85, Clipper
To be truly O-O, they must have two To be truly O-O, they must have two important features:important features:
InheritanceInheritance,, and and
PolymorphismPolymorphism (These are defined and fully explained in Chapter (These are defined and fully explained in Chapter
8)8)
These two features account for a great deal These two features account for a great deal of the power and benefits of O-O methods.of the power and benefits of O-O methods.
98Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.7. Conceptual, Logical & Physical Models
There are a variety of modeling There are a variety of modeling paradigms available: DFDs, ERDs, paradigms available: DFDs, ERDs, Objects, etc.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:
ConceptualConceptual
LogicalLogical
PhysicalPhysical
99Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A physical model is one that shows in A physical model is one that shows in full detail:full detail:
Who will do each processWho will do each process Physically where the data will be stored Physically where the data will be stored What communications medium data will be What communications medium data will be
transferred ontransferred on
4.7. Conceptual, Logical & Physical Models
100Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A A physical model physical model is the final is the final design document showing design document showing how things will be written, how things will be written, done or built, and depicting done or built, and depicting all hardware and software all hardware and software platform details, including platform details, including
data storage and data data storage and data transmission media.transmission media.
4.7. Conceptual, Logical & Physical Models
101Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
At the At the logicallogical level, we build a model level, we build a model that shows everything that must be that shows everything that must be included, and everything that the included, and everything that the
system must do, system must do, withoutwithout specifying specifying
how.how.
It makes no reference to choices of It makes no reference to choices of hardware, software or media.hardware, software or media.
4.7. Conceptual, Logical & Physical Models
102Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A A logical model logical model shows what a shows what a system must do or have, system must do or have,
without regard for without regard for howhow it is to it is to be done, built or represented. be done, built or represented.
4.7. Conceptual, Logical & Physical Models
103Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A A conceptual model conceptual model is like a logical is like a logical
one, except that it shows the one, except that it shows the users’ users’ concept concept of their operation.of their operation.
It will miss out a lot of behind-the-It will miss out a lot of behind-the-scenes activity and structurescenes activity and structure
Things that must be there, i.e., must Things that must be there, i.e., must exist or must happen, even though the exist or must happen, even though the users are mostly users are mostly unawareunaware of them. of them.
These things are added when we later These things are added when we later make a logical model.make a logical model.
It It includes many-to-many includes many-to-many associations.associations.
4.7. Conceptual, Logical & Physical Models
104Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
A A Conceptual Model Conceptual Model is a is a representation of the users’ representation of the users’
business in terms of business in terms of their their conception conception of how it operates. of how it operates.
For ERDs and Object models, this For ERDs and Object models, this means it includes M:M means it includes M:M
associations.associations.
4.7. Conceptual, Logical & Physical Models
105Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
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 logical
model model by adding all the features that by adding all the features that were not apparent to the users.were not apparent to the users.
Finally we make all our design decisions Finally we make all our design decisions
and document them on theand document them on the physical physical model.model.
4.7. Conceptual, Logical & Physical Models
106Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
4.8. 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” 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.”
107Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
The secret to solving all of these is The secret to solving all of these is
CommunicationCommunication, but, but
““The biggest problem The biggest problem with communication iswith communication is
the the illusionillusion that it has that it has taken place!”taken place!”
4.8. Models as Communication Tools
108Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
To build an accurate model, it is To build an accurate model, it is essential that you are essential that you are user-drivenuser-driven in in your modeling.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. ““God gave us two ears and one mouth!”God gave us two ears and one mouth!” Remember, we are using our object-Remember, we are using our object-
oriented techniques to understand oriented techniques to understand theirtheir business.business.
4.8. Models as Communication Tools
109Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
Once the users learn the notation, they Once the users learn the notation, they quickly take to using the model to quickly take to using the model to discuss and solve problems with the discuss and solve problems with the analysts.analysts.
All players on the team and sometimes All players on the team and sometimes outside it can make use of these outside it can make use of these models.models.
4.8. Models as Communication Tools
114Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
115Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
116Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
117Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]
118Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]