Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 'class diagrams' and 'data models' in UML?

Tags:

uml

diagram

I have homework and I'm supposed to draw a class diagram AND data model. I wrote the class diagram. I don't know what to do about the data model. What are the differences?

According to texts on the Internet they seems to me, ie: class diagrams and data models are the same thing.

What is the difference between class diagrams and data models.

like image 539
petko_stankoski Avatar asked Jan 19 '12 13:01

petko_stankoski


1 Answers

Unified Modelling Language, as you may already know, is a means of describing systems with diagrams. They don't just relate to software, but can also relate to hardware, economics, everyday items, in fact anything, although they are more generally used with software systems.

A class diagram details how you have split your system into discrete objects, how those objects relate to each other and any know interfaces that they may have. Each class in a class diagram can hold both data and function.

For example a Car class has an Engine, a Steering Wheel class and multiple Wheel, Door, Seat and Pedal classes linked to it. In all of this a class diagram is static.

I'm not exactly sure what you mean by data model.

I've seen class diagrams used to model database tables, usually these are without any functional element and just show how the data tables relate to each other.

There are those that argue that there needs to be an addition to the UML standard for Data Diagrams, but as yet none have been ratified.

This is because persistence of data, key relationships and constraints between tables can be difficult to model with a standard class diagram and most UML tools implement tweaks to the standard in order to allow this.

Then there are dataflow diagrams which are really Activity diagrams, used to show the flow of data between processes within a system.

Now if we go back to class diagrams and assume that a data diagram is used to model a database then you'll notice that there a few differences that may be overlooked.

A class on a class diagram can have data properties (code variables etc) and functional properties (methods, procedures, functions etc.) but these elements of a class can also have access properties (private, public etc.). A class diagram can also show inheritence e.g. a Volkswagon is a Car, so is a Ford, both will inherit from Car and this can be shown.

A data diagram in the database sense will show data items (columns/fields in database tables) but the idea of access properties (public, private etc.) or the idea of inheritence has no meaning and thus can't be shown.

This is because it isn't modelling discrete objects that have both data and function but the data associated with those objects. For example a Car table may have a relational link to a Manufacturers table in which is stored the values Volkswagon and Ford. It may have a Wheels column, but this will only show the number of wheels. Stored procedures for the database exist at a level labstracted from the data - they utilise the data, but are not governed or owned by the data tables that they get the data from.

I've probably not explained myself very well, but I hope that I've helped.

Here's a useful site

And here's another and on that site data modelling specifically.

like image 164
ChrisBD Avatar answered Oct 05 '22 08:10

ChrisBD