In my business we have a "Data Store" where data is stored (e.g. database, flat file, etc) and a "Data Provider" who delivers the data (e.g. human, sensor, etc).
To model this in UML is no problem for me. BUT, sometimes "instances" are both, a data store and a data provider (e.g. an IoT device). How can I model this?
"An instance can be a data store or a data provider or both".
A data store and data provider have different properties, an instance that is both (a data store and a data provider) should have both properties.
I looked for multiple inheritance or a union concept in UML but did not find the right concept. Can anyone give me a hint how to model this? :-)
EDIT: My primary goal is to develop a conceptual model (not for implementation).
To make something both a "Data Store" and a "Data Provider", you have two choices. The first choice is to multiply classify an instance. The second choice is to instantiate a class that specializes both classes. For either choice, the "Data Store" and "Data Provider" classes must not be disjoint [1].
For the first choice, a UML Instance Specification allows multiple classifiers, which allows you to mix and match classes. If you create an Instance Specification and classify it with both "Data Store" and "Data Provider", you get the effect you are looking for.
For the second choice, UML allows a class to specialize multiple other classes, which allows you to create a subclass of the intersection of those other classes [2]. If you create a class called "Data Store Provider" and use a Generalization arrow to connect it both to "Data Store" and to "Data Provider", you can also get the effect you are looking for.
[1] In UML, you make classes disjoint using a Generalization Set that has the meta-property isDisjoint=true. Don't do that for either of these choices.
[2] In UML, there is no way to express the exact intersection, and most people don't understand why you would want to do that anyway. A plug-in for MagicDraw, called the Cameo Concept Modeler, extends UML so that you can express this, among other things that UML cannot express, so you can model ontologies.
I might have to think a bit more over this, but one way that comes to mind is to use different (optional) ports that realize different interfaces:
Related
I am doing a UML model based on my ERD generated with MySQL workbench. But now i have a doubt about the primary and foreign keys representation in a class diagram.
In the traditional UML diagram we should include the primary keys as atributes of each class? For example, the id_user or the id_list ? And about the foreign keys ? These ones are ignored as attribute but reflected as associations?
thanks
First off: why do you want to draw it in UML? If you already have an ERD, what additional/alternate property do you want to illustrate with a UML class diagram that the ERD doesn't give you?
Why? Because UML is a tool. On the assumption the diagram is for human consumption only (i.e. you're not code generating from it) then you should use UML to expose the information you're trying to communicate.
As a general standard UML says nothing about how you formalise identity (PK/FK). UML follows the OO idiom that every object has implicit identity - therefore you don't need to specify it explicitly. So in the simplest case, you could:
list PK attributes as normal attributes;
ignore FK attributes altogether.
If that meets your modelling needs then you're done.
As a second refinement, you could tag the PK attributes with an ocl isUnique() constraint, again ignoring the FKs.
Another option would be to use the rules of Executable UML. It denotes both PKs ('Identifiers'} and FKs ('referential attributes'} directly on the class diagram. So it's closest to capturing everything in the ERD.
So in summary: there is no UML-imposed right answer. It all depends on what you want to communicate with the diagram.
You can use/create a "database profile" to annotate your UML model with this information. Without a profile you could use OCL to specify uniqueness constraints while normal associations should be enough to represent what would be transformed into foreign keys at the database level
You can use EclipseUML Omondo trial and reverse your database.
You will get the information you need and you can then copy it in a free or open source tool.
I have been told to create an analysis diagram but it states that only date classes should be added. I thought that is what you use anyway, or am I thinking about this wrongly
"The models include a domain/analysis class diagram (which contains data classes only)"
I wouldn't ever use this terminology but my guess is that the instructor/manager wants your model to contain only the classes that will be later on implemented in the database (i.e. those that represent the concepts that you´ll need to store information about). To me this set coincides with what I´d refer to as domain classes but maybe your instructor has a different interpretation
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.
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.
Generally data models define how the database is implemented. Those diagrams are entity diagrams. A class model is the functional relationships between objects in your system. A class has data but it isn't the data model. A design has both a class model and a data model. As a simple example, a data model exists for a customer. That data model was the design for our customer database. A class model design exists to implement how to process a customer order. The data model is what the database designer uses. The class model is what the software designer uses to implement a ordering business function. Both the data model and class model have diagrams. They use different symbols and rules. Class diagram vs Entity diagram. Two different kinds of diagrams.
Datamodeling is not UML which is focused on object approach.
Having said that you can model inside a class diagram at object level and create your database using Hibernate annotations in the Java code.
I mean that you create your code and add persistence annotation at the same time. This would create your database at deployment.
UML which is not supposed to be datamodeling can also create data at deployment level if you use the Omondo Persistence profile. It means that you can model at object level and also create your database. Very powerful approach because the data creation stage is now joined with the object
This is still an initiative but it could become a standard if bigger companies adopt this approach which is for me one of the best practices when codding in Java that I would recommend.
Just wondering what's the correct UML Diagram type to show Service Connection? Essentially saying that "Client A needs a function GetFoo that needs to return items whose quantity is bigger than 20" and "Client B needs a function GetFoo that returns all items"?
A Component Diagram looks correct, but already very concrete in terms of types and very vague in terms of single functions. Composite Structure maybe?
Eventually this is used during planning to decide which functions a service actually needs to have (e.g., an inner GetFoo and two outer GetHeavyFoo/GetAllFoo functions)
I think the composite structure diagram will work for you. However, in my opinion you should combine it with sequence or communication diagram or both - whichever works best for you. I also suggest you check all the uml diagrams and compare them and then decide which ones are best suited for you.
Component diagram is a good solution as well as Sequence.
If you are a beginner in UML you can also just create a class diagram and add a constraints on a method. It would do the job and be easy to understand by the developer team.
It used to be OCL in UML 1.X but now with UML2 direct access to the metamodel you can just create any constraints directly in the model without any transformation. I use EclipseUML Omondo and don't want to use OCL because too complex for a very limited return on investment. My workaround is also better because I can write whatever I want and directly put it inside my class diagram without having two different models (e.g. one for UML and one for OCL).
I have read several tutorials on what a UML model should contain and what not. As a developer I always think in terms of a relational data model where you could never have a many to many relationship between tables. Now with a UML class model, I've read that if they don't provide added value, you could just skip the linktables.
However I've also read a tutorial where examples where given using data inside tables and was strongly suggesting to picture each class as a simple table while modeling your class model.
I am confused, what is it now?!
The "relational link table" is an implementation technique for a Many-to-Many relationship.
The relationship exists irrespective of how it's implemented.
In an object model, you have many choices for how to implement many-to-many, which may (or may not) involve an additional persistent table. It could be done lots of different ways.
The point of UML is to be able to describe the essential features of what the model really is.
You can also describe the implementation. They're separate diagrams with separate purposes. You can easily show the relational implementation with the link table. You can also show the essential model without the link table.
Here's the essential relationship
Here's the implementation of the relationship
Both are valid UML. The real question is "what do you need to show other people?" Essential truth or one particular implementation?
Model it as an M:N relationship. Same as in a relationship model there will be an associate class (or link class) of some kind in code. No need to put that on the diagram unless it has attributes on top of the join attributes (much like you would generally omit a join entity from an ERD unless it had attributes that weren't foreign keys in the related entities). The link class is typically drawn as a class connected to the relationship by a dashed line.
The Enrolment join entity is a good example of this in UML 2 Class Diagrams.