24
UML for Data Architects: A Painless Introduction A Painless Introduction Dr. Vladimir Bacvanski [email protected]

UML for Data Architects

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: UML for Data Architects

UML for Data Architects:A Painless IntroductionA Painless Introduction

Dr. Vladimir [email protected]

Page 2: UML for Data Architects

About the Speaker: Dr. Vladimir Bacvanski

Mission: to make organizations successful in solving problems through adoption of modernsolving problems through adoption of modern software technologies– Founder of SciSpike – a training and consulting firm

specializing in advanced software technologies– Over two decades of experience with software and data

technologies– Vladimir has helped a number of organizations

including US Treasury, Federal Reserve Bank, US Navy, IBM, Dell, Hewlett Packard, JP Morgan Chase, Nokia, gLucent, Nortel Networks, General Electric, BAE Systems, AMD, and others

– Frequent speaker at leading industry events.q p g y– For three years in a row awarded the title "IBM

Information Champion" for his contributions to the information management community

www.scispike.com Copyright © SciSpike 2011

g y

2

Page 3: UML for Data Architects

Outline

What is UML?

How to approach UML? (aka "Avoiding pain")

UML diagrams: use only what you need!g y y

Representing structure: class (aka type) diagrams

UML for database design UML for database design

Automation

Conclusion

www.scispike.com Copyright © SciSpike 2011 3

Page 4: UML for Data Architects

What is UML?

The UML is a graphical language for fsoftware intensive systems

– Note: UML is just a notation: h i li d i ithe way we visualize our decisions

UML covers a broad area of software d l tdevelopment

UML is a standard: it enables you to d l i th texpress your models in a way that

can be understood by others

www.scispike.com Copyright © SciSpike 2011 4

Page 5: UML for Data Architects

Models and Diagrams

Model is a view of a system from a particular perspective

Diagram visually presents elements of a model Diagram visually presents elements of a model

– One model can be presented with several diagrams, each focusing on a separate aspect

www.scispike.com Copyright © SciSpike 2011

focusing on a separate aspect

5

Page 6: UML for Data Architects

UML Diagrams

www.scispike.com Copyright © SciSpike 2011 6

Diagrams in italics are introduced in UML 2

Page 7: UML for Data Architects

Choose your Approach to UML!

Painful Painless

• Focus on > 95% of UML th t d 't d

• Focus on < 5% of UML th t dthat you don't need

• Start with a 1000+ pages UML Reference

that you need • Start with a subset

relevant to datapages UML Reference • Avoid practical

examples

relevant to data modeling

• Seek practical guidesexamples• Use UML for all the

wrong reasons

Seek practical guides and examples

• Use UML to communicate and automate

www.scispike.com Copyright © SciSpike 2011 7

Page 8: UML for Data Architects

Modeling Data with UML Class Diagrams

A subset of UML Class Diagram is very close to notations d d d lused in data modeling

UML Class Diagrams have features not needed for data d lmodeling:

– Operations (methods)– Visibility (public, private, …)

We can use only a subset that make sense for data modeling:

– Classes (aka "types")– Attributes– Associations– Generalization

www.scispike.com Copyright © SciSpike 2011 8

Page 9: UML for Data Architects

UML Classes and Attributes

Customer

ClassSimilar to entity in ERD.

CustomerClass nameTypically capitalized.

Attribute CompartmentThe only compartment we care about. UML classes can have other compartments, e.g. for operations.It is fine to skip parts we don't need!p p

N tAttribute TypeE.g. String, Integer,… 

Attribute NameTypically 

Note:High level class diagrams typically don't 

www.scispike.com Copyright © SciSpike 2011 9

but also other class nameslowercase.  need primary and foreign keys. 

Page 10: UML for Data Architects

UML Associations

Association Association NameUsually skipped.

Multiplicity*: zero or many1..*: one or many0..1: zero or one

Association RoleStart from a class follow the Note:Start from a class, follow the association, read the role of the associated objects.

Foreign key attributes are not needed

www.scispike.com Copyright © SciSpike 2011 10

Page 11: UML for Data Architects

Navigability

Person Address*1..*

homeAddress

High level diagrams typically do not show navigability

Navigability is a design decision!Navigability is a design decision!

– It is a bad practice to assign navigability prematurely– Typically not needed for modeling when we target– Typically not needed for modeling when we target

relational databases

www.scispike.com Copyright © SciSpike 2011 11

Page 12: UML for Data Architects

Associations vs. Attributes

P CM lti li it

employer: Company[*]

Person

employee: Person[1..*]

CompanyMultiplicity

p y p y[ ] p y [ ]

In UML, attributes and associations are equivalent!

Choose the representation that is more suitable to the reader

Important relationships are often represented as associations – they bring the visual emphasis

www.scispike.com Copyright © SciSpike 2011 12

Page 13: UML for Data Architects

Association Class

Association ClClass

Association class allows to attach information to an associationassociation

– Often refined into two associations to a class

www.scispike.com Copyright © SciSpike 2011 13

Page 14: UML for Data Architects

Association Class Refined

Association classes are commonly refined in lower level ydiagrams

www.scispike.com Copyright © SciSpike 2011 14

Page 15: UML for Data Architects

Semantics of Aggregation and Composition

Car Engine1

Aggregation

Car Engine1

Aggregation: shortcut for "has" relationship

Composition

Aggregation: shortcut for has relationship

– Does not have a well defined semantics. Use sparingly! Composition lifetime of the owner determines the lifetime Composition: lifetime of the owner determines the lifetime

of the owned objects

Similar to "cascading"

www.scispike.com Copyright © SciSpike 2011

– Similar to cascading

15

Page 16: UML for Data Architects

Generalization (aka Inheritance)

EmployeeG li iGeneralization

ManagerEngineer TechWriter

Subclasses extend superclasses with additional attributes Subclasses extend superclasses with additional attributes and associations

This relationship eventually needs to be mapped to tables This relationship eventually needs to be mapped to tables for relational database design– Several solutions possible with different performance impact Choice

www.scispike.com Copyright © SciSpike 2011

Several solutions possible with different performance impact. Choice depends on the typical pattern of usage.

16

Page 17: UML for Data Architects

Constraints

Constraints can be expressed as:

– Plain text– OCL: Object Constraint Language, part of UML

• Not common in mainstream projects• Enforcable

www.scispike.com Copyright © SciSpike 2011 17

Page 18: UML for Data Architects

Organizing UML Models: Packages

A package is a structuring element

– It contains other Customer

Management

elements and diagrams

P k i Packages are important for managing complexity of models

Sales

complexity of models

Prefer models organized into packages to hugeInventory into packages to huge diagrams

Inventory

www.scispike.com Copyright © SciSpike 2011 18

Page 19: UML for Data Architects

Mapping UML to ER Models…

Class Entity

– Add primary key

Simple Attribute Type Column Type

Complex Attribute Type Relationship to an entity for the attribute type

Association Foreign Key relationships

– Use role names for foreign keysUse role names for foreign keys– Many-to-many association add an associative table– Aggregation: treat as ordinary relationshipsAggregation: treat as ordinary relationships

www.scispike.com Copyright © SciSpike 2011 19

Page 20: UML for Data Architects

…Mapping UML to ER Models

Generalization: use the usual mappings:

– Table per class hierarchy– Table per subclass– Table per concrete class

Constraints

– Set constraints on the database– Some only enforceable in application logicy pp g

This is just a simplified set of rules to get you going!

www.scispike.com Copyright © SciSpike 2011 20

Page 21: UML for Data Architects

UML for Database Design

Agile teams often use UML for both software and database design

UML data modeling profile introduces extensions to UML:– <<PK>>, <<FK>>, <<Auto Generated>>, <<Not Null>>,

<<View>>, <<Stored Procedures>>,…

Use relational data types

www.scispike.com Copyright © SciSpike 2011

– String CHAR(x), VARCHAR(x)

21

Page 22: UML for Data Architects

Automation

Code

TransformerDDL

InputModels Models

Tools can convert from UML to ERD and vice versa

Output

Tools can convert from UML to ERD and vice versa

Model transformation tools operate at a MOF/EMF level and can transform UML to various targetscan transform UML to various targets– Visual Domain Specific Languages (DSLs) based on UML may provide

better alignment with the problem domain than vanilla UML

www.scispike.com Copyright © SciSpike 2011

g p

22

Page 23: UML for Data Architects

Conclusion

You will need just a small part of UML!

UML is a common starting point for data models

Mapping of UML to ER is quite straightforwardpp g q g

Knowing UML makes you a more significant player in the software development processp p

www.scispike.com Copyright © SciSpike 2011 23

Page 24: UML for Data Architects

Getting in Touch

Email: [email protected]

Blog: http://www.OnBuildingSoftware.com/

Twitter: http://twitter.com/OnSoftwarep

LinkedIn: http://www.linkedin.com/in/VladimirBacvanski

SciSpike Training and Consulting: http://www scispike comhttp://www.scispike.com

– Related training for data architects: Visual Modeling with UML• Visual Modeling with UML

• Mastering Data Modeling with InfoSphere Data Architect

www.scispike.com Copyright © SciSpike 2011 24