1
Part 2
Introduction to Unified Modeling Language UML
Levels of modelling Conceptual Model • Formally describes the content and structure of a data set • Describes the Universe of Discourse: a view on the real-world, depending on the aimed application(s) • Is software/platform independent • Is generally described using a graphical conceptual language (e.g. UML)
2
Levels of modelling Logical Model • Closer to implementation, but still emphasis on information content and how it is structured, constraints, etc...
Physical storage Model • How it is actually stored/encoded (detailed instructions), also indexes, table spaces, binary compression methods, etc...
3
Levels of modelling
4
UML basics
5
(acknowledgement goes to Julien Gaffuri – DG JRC)
• Purpose of slides: give basis to read INSPIRE UML class diagrams. • Notions: Class, Attribute, Operation, Association, Constraint, Package, Stereotype...
UML class diagram
INSPIRE UML class diagram for administrative units
6
Class
7
Definition: description of a set of objects that share the same attributes, operations, relationships, and semantics.
Class UML representation: Simple view
Full view
ClassName
ClassName
+ AttributeName : DataType ... + OperationName(parameter1Name : DataType) : outDataType ...
8
Class: Attribute
9
Definition: characteristic common to all the objects of a class. visibility name [multiplicity] : data-type = value • Visibility: + (public) or – (private) (always + in INSPIRE) • Multiplicity: number of values (optional) • Value: possible default values (optional)
Class: Operation
10
Definition: An operation (or method) is a service that can be requested from an object. visibility name (parameters): outDataType • parameters: list of parameters (a parameter = a name + a data type)
Class
11
Example: Car + seatNumber : int + color [1..*] : Col + repair(tool : Tool) : Bill + wash() : void
« A car is characterised by a seat number and one or several colours. » « A car can be repaired. This operation returns a bill to pay » « A car can be washed » …
Inheritage / generalisation
12
Definition: taxonomic relationship between a more general element and a more specific element. Representation: ClassA
ClassB « A classB instance is also a classA instance » « classB instances share the same characteristics as class A instances » « classB specialises classA » « classA is more abstract / generalised than classB » ...
Inheritage / generalisation Example: Vehicule ownerName : String constructionDate : Date
Car
Boat draft : float
Bus passengerNb : int
« Cars, boats, and buses are vehicules » « All vehicules have a construction date » « A bus is a vehicule with a passenger number value » …
13
14
Association
Definition: relationship between classes that specifies connections between their instances. roleA
ClassA
0..2
AssociationName
roleB ClassB *
Example: Company
employer 1..*
Employment employed Person 0..*
Multiplicity-Cardinality
15
Definition: number of instances of a class that may be associated with a class at the other end of the association. Possible values: • • • •
Fixed: ‘1’, ‘2’, ‘n’, etc. Any: ‘*’ Several: ‘0,1’, ‘0,2,4’ Within an interval: ‘0..1’, ‘0..*’, ‘1..*’, etc.
Multiplicity-Cardinality
16
Examples: Company
employer
Employment
employed Person 0..*
1..*
« Companies and persons are linked with an employment relation » « A person can be employed by several companies » « A compagny has to employ at least one person » parent
Kinship
2 Individual
0..* child
« There is a kinship relation between individuals » « All individuals have exactly 2 parents » « Each individual can have several children »
17
Aggregation
Definition: Aggregation relationship between instances of a class and several instances of another class AggregateClass
AggregatedClass 0..2
*
« A classA instance is a an aggregate of instances of classB »
Example: Country
Region 1
*
« A country is an aggregation of regions »
18
Composition
Definition: Composition relationship between instances of a class and several instances of another class (they cannot exist independently) CompositeClass
ComponantClass 0..2
*
« A classA instance is a a composite of instances of classB »
Example: Book
Page 0..1
2..*
« A book is composed of pages (at least two) »
19
Navigability Definition: Indication on the navigation supported by an association ClassA
supplier 0..2
user ClassB *
« A classB instance knows the classA instances it is associated with » « It is not necessary to retrieve ClassB instances linked to a ClassA instance »
20
Note
Definition: Comment or a constraint attached to a diagram element • Usually linked to the element it is related to (with dashed line) • In natural language
ClassA Comment on classA
21
Constraint
Definition: condition or restriction to satisfy. • Can be represented in {…} or in a note • In natural language, or OCL (when possible) • OCL = Object Constraint Language ClassA ClassA objects should be like this
{ClassA objects should be like that}
22
Package Definition: A package is a set of classes
• Defined according to some needs of decomposition of UML models. • UML representations: PackageX ClassA ClassB
PackageX ClassA
0..2 *
ClassB
PackageX
Package diagram
23
Definition: representation of the relations between packages. • Provides a higher level of abstraction.
Package diagram
24
INSPIRE package diagram for administrative units
25
Stereotype Definition: Stereotypes extend the semantics, but not the structure of pre-existing UML elements (classes, attributes, operations, associations, roles, packages) UML representation:
> ClassName
> + AttributeName : DataType
26
Stereotype Examples: : set of values without identity : data type with named literal values (ex: Boolean – TRUE, FALSE) : extendable enumeration
27
Stereotype INSPIRE stereotypes: : for spatial object classes. : element that may not be present : class that will be specified in the future
28
What is it ?
INSPIRE UML class diagram for administrative units
29
Example CityModel Usage: string *
Owner Identification: string
Building Type: string
Name: string
Parcel Parcel ID: string
Adress: string *
Area: float
Private company Type: string NumberOfEmpl: integer
Private person IncomeTax: float
30
30
Nesting vs normalisation • UML diagrams often explains nested structures (complex in XML) • Most databases are normalised – Simple structures (simple XML files) – Independent tables (more or less)
• The same conceptual model can be implemented in various ways • Can we transform a XML file from one schema to another?
31