Download - ADMS-BIS Bouwkundige Informatiesystemen ADMS 2006 UML part 2 Jan Dijkstra - 30 oktober 2006
AD
MS
-BIS
Bouwkundige InformatiesystemenADMS 2006
UML part 2
Bouwkundige InformatiesystemenADMS 2006
UML part 2
Jan Dijkstra - 30 oktober 2006
AD
MS
-BIS
SubjectsSubjects
• Objects & ClassesObjects & Classes 16 16 oktokt..
• UML : Class DiagramUML : Class Diagram 23 okt23 okt..• UML : Object DiagramUML : Object Diagram 23 okt.23 okt.
• UML : Class Diagrams ExercisesUML : Class Diagrams Exercises 23 okt.23 okt.
• Exercise Class Diagram MKWExercise Class Diagram MKW 23 okt23 okt..• Discussion Exercise Class Diagram MKW 30 okt.
• UML : Class Diagrams - Advanced Concepts 30 okt.
• Task UML-part 2 30 okt.
AD
MS
-BIS
Exercise 30 OctoberExercise 30 October
Ga uit van de MKW beschrijving van oefening van UML1
• Identificeer enkele klassen
• Geef zo mogelijk relaties tussen klassen aan
AD
MS
-BIS
An object is a thing that can be tangible or intangible.Examples• tangible : bike, car, house• intangible : order, account
ObjectsObjects
An object has properties.Example• a Customer has a
name and address
Customer
NameAddress
AD
MS
-BIS
Property of object = attribute + value
(Multiple) Objects(Multiple) Objects
Adacs: Customer
Name = AdacsAddress = Enschede
Primo: Customer
Name = PrimoAddress = Grave
Multiple objects unique identity
1247: Customer
Custno = 1247Name = AdacsAddress = Enschede
9378: Customer
Custno = 9378Name = PrimoAddress = Grave
AD
MS
-BIS
Link = connection between objects
Connection between ObjectsConnection between Objects
1247: Customer
Custno = 1247Name = AdacsAddress = Enschede
345T7: Order
Orderno = 345T7dateReceived = 10/10/05Price = 1987
902U2: Order
Orderno = 902U2dateReceived = 07/04/05Price = 3789
AD
MS
-BIS
Class• class is abstract concept• each object is instance of a class• classes classify objects• attribute has no values
ClassClass
Customer
CustnoNameAddress
Order
OrdernodateReceivedPrice
Object analysis than values to attributes
AD
MS
-BIS
• Attribute has no values• Association is relation between classes
Class DiagramClass Diagram
Customer
CustnoNameAddress
Order
OrdernodateReceivedPrice
Link is instance of association
1 *
AD
MS
-BIS
Advanced Class FeaturesAdvanced Class Features
AD
MS
-BIS
Advanced Class Concepts : VisibilityAdvanced Class Concepts : Visibility• Visibility – class members (attributes, operations) may be
specified as:{we have feature f, an attribute or operation that is defined on an object O of class C }– + : public{f is public f is visible to any object and f is inherited by the subclasses of C.}– # : protected{f is protected f is visible only to objects of class C and to objects of C’s
subclasses and f is inherited by the subclasses of C.}- : private{f is private f is visible only to O and f is not inherited by the subclasses of
C.}
• Restricting visibility is the same as restricting accessibility.
AD
MS
-BIS
Advanced Class Concepts : ScopeAdvanced Class Concepts : Scope
• Individual member data (= attributes) may have:– Class scope : a single copy of an attribute is shared by all
instances of a class.– Instance scope : each instance of a class would have its
own copy of the attribute.
AD
MS
-BIS
Advanced Class Concepts : AbstractAdvanced Class Concepts : Abstract
• An operation is abstract if it has no implementation.
• A abstract class cannot have any direct instances.
• Abstract classes only occur in the context of an inheritance hierarchy.
• Abstract operations and classes are specified by writing its name in italics.
AD
MS
-BIS
Advanced Class Concepts : AbstractAdvanced Class Concepts : Abstract
AD
MS
-BIS
Window as Abstract ClassWindow as Abstract Class
AD
MS
-BIS
Characteristics of Object Oriented Design (OOD)Characteristics of Object Oriented Design (OOD)
• Data and operations (functions) are combined objectobject
• Objects arte abstractions of real-world or system entities and manage themselves.
• Objects are independent and encapsulate state and represent information.
• System functionality is expressed in terms of object services.
• Objects communicate by message passing.
AD
MS
-BIS
• Objects are abstractions of real-world entities.
• Objects encapsulate state and represent information.
• Object’s state is protected.
• Objects have responsibility.
• Objects interact by interfaces.
AD
MS
-BIS
Conceptions Conceptions
• Encapsulation • Information hiding• Responsibility
AD
MS
-BIS
EncapsulationEncapsulation
• Encapsulation is the grouping of related ideas into one unit, which can thereafter be referred to by a single name.– Object-oriented encapsulation is the packaging of operations
and attributes representing state into an object type so that state is accessible or modifiable via the interface provided by the encapsulation.
AD
MS
-BIS
Information hidingInformation hiding
• Information hiding is the use of an encapsulation to restrict from external visibility certain information decisions that are internal to the encapsulation structure.
AD
MS
-BIS
ResponsibilityResponsibility
• Object oriented design is a responsibility driven design approach.– Objects have responsibilities that they prove oneself.– Therefore, collaboration with other objects is needed.
AD
MS
-BIS
Classes and ObjectsClasses and Objects
• Objects looks like modules in some ways
Object = Identity + State + BehaviourObject = Identity + State + Behaviour• Objects provide encapsulation of data• An object is described by a classobject is described by a class. A class may define a
number of objects with identical properties
AD
MS
-BIS
About an ObjectAbout an Object
• An object has a public interface defining the operationsoperations (methods) it will support
• An object has private data called attributesattributes, which only its own operations can access
• An object can have private operations for its own use• An object may know about other objects by means of linkslinks
AD
MS
-BIS
Structural modeling essentialsStructural modeling essentials
Attributes Operations
Responsabilities
Class
AD
MS
-BIS
Look back: Class - operationsLook back: Class - operations
• An operation is the implementation of a service that can be requested from any object of the class in order to affect behaviour.• Operations are used to manipulate the attributes or to perform other actions. Operations are normally called functions, but they are inside a class and can be applied only to objects of that class. • An operation is described with a return-type, a name and zero or more parameters. Together, the return-type, name, and parameters are called the signature of the operation.• The signature describes everything needed to use the operation.
AD
MS
-BIS
AD
MS
-BIS
Aggregation and Composition Aggregation and Composition • Aggregation is a special form of association that specifies a whole-
part relationship between the aggregate (the whole) and a component (the part); aggregation is the part-of relationship.{ it is a special form of association in which a collection of objects, each having an independent existence, is associated with an single object} {unfilled diamond}
• Composition is a form of aggregation with strong ownership and coincident lifetime of the parts by the whole; the part object may belong to only one whole – the parts are usually expected to live and die with the whole. {usually, any deletion of the whole is considered to cascade to the parts} {filled diamond}
AD
MS
-BIS
Aggregation and Composition: ExampleAggregation and Composition: Example
AD
MS
-BIS
Derived Associations and AttributesDerived Associations and Attributes
• Derived associations and attributes can be calculated from other associations and attributes, respectively, on a class diagram.– For example, an age attribute
of a Person can be derived if you know that Person’s date of birth.
AD
MS
-BIS
Relations and ConstraintsRelations and Constraints
AD
MS
-BIS
UML for Database DesignUML for Database Design
• Database– A database is a collection of data.
– Databases can be stored in one or more files, or can be managed by a software system called Database Management System (DBMS)
• What makes a database– Add Data
– Delete Data
– Change Data
– Lookup or search for data
– Organize Data
AD
MS
-BIS
Key TerminologyKey Terminology
• Table• Column• Record• Field
• Primary Key• Foreign Key
AD
MS
-BIS
Database Diagram ElementsDatabase Diagram Elements
• Table• Column• Primary key• Foreign key• Identifying relationship• Non-identifying relationship
AD
MS
-BIS
Database Diagram Elements (2)Database Diagram Elements (2)
Table (stereotype <<table>>)
Not used
Not used
Primary key (stereotype <<pk>>)
Foreign key (stereotype <<fk>>)
Primary/Foreign key (stereotype <<pk/fk>>)
Non-identifying relationship
Identifying relationship
AD
MS
-BIS
Example 1Example 1
AD
MS
-BIS
Mapping Logical Design To Database Design
Mapping Logical Design To Database Design
• Synchronization• Classes > Tables• Attributes > Columns• Associations > Relations• Normalization• There are more ways to do it
AD
MS
-BIS
Mapping Classes To TablesMapping Classes To Tables
• Map persisted classes to tables• Many to many associations must be broken down to one to many
associations using an association table.
«pk» +Class1ID
«table»Class1
«pk» +Class2ID
«table»Class2
«pk/fk» +Class1ID«pk/fk» +Class2ID
«table»Association Class
1
*
1
*
AD
MS
-BIS
Mapping Subtype Classes to TablesMapping Subtype Classes to Tables
• One table per class
• One table per concrete class
• One table per hierarchy
AD
MS
-BIS
Mapping Attributes to ColumnsMapping Attributes to Columns
• Map persistent attributes• Don’t map calculated attributes• Can use Generic Types first, later use database specific
types.
Generic Types: Boolean, Currency, Date, Double, Integer, Long, Single, String
AD
MS
-BIS
Example 2Example 2
AD
MS
-BIS
Example ProjectenExample Projecten
-<<pk/fk>> naam-<<pk/fk>> projectnr-startdatum-einddatum
<<table>> Leiding1
*
1
*
-<<pk>> naam-afdeling-leeftijd
<<table>>Projectleider -<<pk>> projectnr-starttijd proj-duur proj-budget
<<table>> Project
AD
MS
-BIS
Database ExampleDatabase Example
«pk» +ISBN+Title+Description
«table»Book
«pk» +BookID«fk» +ISBN+Count
«table»LibraryBook
«pk» +ClientID+Name+Adres
«table»Client
«pk/fk» +ClientID«pk/fk» +BookID+Lend+Days
«table»BookClient
1
*
1 *
1 *
AD
MS
-BIS
NormaliserenNormaliseren
• Het verfijnen van een informatiebehoefte en het verder detailleren van een gegevensmodel wordt normaliseren genoemd.
• Normaliseren gebeurt in een aantal stappen die leiden tot zogenaamde normaalvormen. Met een denkproces kan men tot hetzelfde komen zonder dat men de specifieke normaalvormen hanteert.
• Uitgangspunt is een ongenormaliseerde groep, dwz alle gegevens elementen worden geidentificeerd.
AD
MS
-BIS
VoorbeeldVoorbeeld
Het lenen van boeken bij de bibliotheek; er kunnen meerdere exemplaren van een boek zijn.
Gegevens:
ISBNtitelomschrijvingboekidentificatieaantalleendatumlenerlenernaw
AD
MS
-BIS
Normaliseren 1Normaliseren 1
• Allereerst worden procesgegevens verwijderd en wordt een repeterende groep afgesplitst. De oorspronkelijke sleutel wordt overgenomen; deze zorgt voor de koppeling (relatie, associatie) tussen de groepen. Deze sleutel is niet voldoende samen met een ander gegeven vormt het een samengestelde sleutel. (1eNV)
boekidisbntitelomschraantalleneridleendatumlenernaw
boekidisbntitelomschraantal
boekidleneridleendatumlenernaw
AD
MS
-BIS
Normaliseren 2Normaliseren 2
• Daarna geldt dat attributen functioneel afhankelijk moeten zijn van de gehele sleutel. Dat betekent dat de attributen die slechts van een gedeelte van de sleutel afhankelijk zin, in een aparte groep worden opgenomen. (2eNV)
boekidleneridleendatum
boekidisbntitelomschraantal
boekidleneridleendatumlenernaw
boekidisbntitelomschraantal lenerid
leennaw
AD
MS
-BIS
Normaliseren 3Normaliseren 3
• Daarna worden ook attributen die ook functioneel afhankelijk zijn van andere niet-sleutelattributen in aparte groepen genomen. (3eNV)
boekidleneridleendatum
boekidisbntitelomschraantal lenerid
leennaw
boekidisbnaantal
isbntitelomschr
boekidleneridleendatum
leneridleennaw
AD
MS
-BIS
ResultaatResultaat
BIBBOEKBIBBOEKboekidisbnaantal
BOEKBOEKisbntitelomschr
BOEKLENERBOEKLENERboekidleneridleendatum
LENERLENERleneridleennaw
AD
MS
-BIS
Database Desktop ExampleDatabase Desktop Example
«pk» +ISBN+Title+Description
«table»Book
«pk» +BookID«fk» +ISBN+Count
«table»LibraryBook
«pk» +ClientID+Name+Adres
«table»Client
«pk/fk» +ClientID«pk/fk» +BookID+Lend+Days
«table»BookClient
1
*
1 *
1 *
AD
MS
-BIS
QuestionnaireQuestionnaire
A market research company develops written questionnaires for customers, carries out the market research and presents the results to the customer. The company would like to develop an information system to help them in their work. The information system is based on the following description.
A questionnaire consists of a number of questions. Each question can appear in one or more questionnaires. A question always has one or more possible answers and each possible answer can be associated with one or more questions (for example, an answer "Yes" can be given to a large number of questions in the questionnaire). The chosen answer results in a number of points. The number of points depends on the combination of the question for which the answer was given and the questionnaire in which the question was asked.
The answers given for a filled-in questionnaire are registered per question. The person filling in a questionnaire can also give a comment with some questions. He or she can also give a comment on the questionnaire as a whole. These comments are all registered in the information system. Comments with questions or on the questionnaire as a whole are not mandatory. Make a class diagram showing the most important object types. State any assumptions that you have made. Only functional relationships are allowed in the class diagram.
AD
MS
-BIS
Questionnaire 1Questionnaire 1
Questionnaire A101 CustomA Questions Answers Points
Question_A answer_1 points0answer_3 points1answer_4 points7
Comment Question_B answer_2 points9
answer_3 points2Comment ------- ------ ------ Comment questionnaire
Questionnaire B341 CustomC Questions Answers Points
Question_A answer_1 points4answer_4 points1answer_7 points2
Comment Question_D answer_4 points9
answer_3 points2Comment ------- ------ ------ Comment questionnaire
AD
MS
-BIS
Questionnaire 2Questionnaire 2
Gegevenselementen Qn_id[custom]Qn_comQuest_idQuest_txtQuest_comAnsw_idAnsw_txtPoints
Qn_id[custom]Qn_com
Quest_idQuest_txtQuest_com
Answ_idAnsw_txtPoints
AD
MS
-BIS
Questionnaire 3Questionnaire 3
QuestionnaireQn_idQn_id Quest_idQuest_id[custom] Qn_idQn_idQn_com Quest_txt
Quest_comAnsw_idAnsw_txtPoints
AD
MS
-BIS
Questionnaire 4Questionnaire 4
Questionnaire QuestionQn_idQn_id Quest_idQuest_id Answ_idAnsw_id[custom] Qn_idQn_id Quest_idQuest_idQn_com Quest_txt Qn_idQn_id
Quest_com Answ_txtPoints
Questionnaire Question Answers AnswTxtQn_idQn_id Quest_idQuest_id Answ_idAnsw_id Answ_idAnsw_id[custom] Qn_idQn_id Quest_idQuest_id Answ_txtQn_com Quest_txt Qn_idQn_id
Quest_com Points
AD
MS
-BIS
Questionnaire 5Questionnaire 5
-<<pk>>Qn_id-custom-Qn_com
Questionnaire
-<<pk>>Quest_id-<<pk/fk>>Qn_id-Quest_txt
Question
1 1..*
-<<pk/fk>>Quest_id-<<pk/fk>>Qn_id-Quest_comtxt
QuestComment
1 *
-<<pk>>Answ_id-<<pk/fk>>Quest_id-<<pk/fk>>Qn_id-Points
Answers
1
1..*
-<<pk>>Answ_id-Answ_txt
AswerTxt
1 1
AD
MS
-BIS
Map to DataBase ModelMap to DataBase Model
• Design DB use• Realize DB system
• For Example
• Realization DB system by MS ACCESS
AD
MS
-BIS
MS Access DB Design (1 of 5)MS Access DB Design (1 of 5)
AD
MS
-BIS
MS Access DB Design (2 of 5)MS Access DB Design (2 of 5)
AD
MS
-BIS
MS Access DB Design (3 of 5)MS Access DB Design (3 of 5)
AD
MS
-BIS
MS Access DB Design (4 of 5)MS Access DB Design (4 of 5)
AD
MS
-BIS
MS Access DB Design (5 of 5)MS Access DB Design (5 of 5)