The Entity-relationship (ER) was (well, still is in the database community) a popular modeling language to define the (static) conceptual schema of your system. UML class diagrams (with a bit of help from OCL) can be regarded as a superset of the ER language, which explains why ER is slowly disappearing (e.g. some years ago, Extended ER was still taught in database courses while UML was taught in software engineering courses, while now most universities are shifting towards using UML in both kinds of courses).
Nevertheless, there is one thing I do miss from my times as ER modeler. The simplicity of defining external identifiers for each type/class by just underscoring the name of the attribute/s that can be used to identify a single instance of the class. Instead, to do this in UML you need to write an OCL constraint that enforces the uniqueness of the attribute/s (and then, of course, you’ll need somebody/some tool able to understand OCL, to detect that the OCL expression has this uniqueness semantic and enforce the same semantics at the code level).
You could argue that UML is object-oriented so each instance of a class has its own internal identifier. True, but “humans” don’t work with internal identifiers but with external ones. Therefore, when implementing any application you’ll be forced to provide search and query capabilities that allow users to retrieve the objects they are interested in based on their external identifier.
So, since I believe external identifiers are an important concept I propose to add them to the next version of the standard !!! There are so many things already in the standard that one more would not make it worse 🙂
FNR Pearl Chair. Head of the Software Engineering RDI Unit at LIST. Affiliate Professor at University of Luxembourg. More about me.
It would be great that UML adopts the same notation: underscoring an attribute would mean this attribute is part of the “external identifier”. But…
Btw, I still use “the underscoring way” at work 😛
I miss attributed relationships. In an ER model, this is really simple to do and to translate to a relational database.
What’s the difference between attributed relationships and association classes?
Oups. I think I was too fast on my comment and I forgot the association classes.. 😉 .
Anyway, when the objective is to translate UML into OO code, I think an association class is not very intuitive. But this is another problem..
What it’s true is that for me it was much easier to explain that a relationship could have attributes than the concept of association class. Difficult to make students quickly understand something that it’s at the same time an association and a class!
Jordi —
As a matter of fact, this has already been added to UML!
As of UML 2.4, properties have the meta-attribute “isID”, which had the definition: “True indicates this property can be used to uniquely identify an instance of the containing Class. Default value is false” (UML 2.4 spec, subclause 7.3.45 Property). This the particular impetus for adding this to UML 2.4 was to allow the MOF 2.4 metamodeling language to be a strict subset of UML 2.4, and previously MOF had had to add isID as an extension to UML (Package::URI was similarly added in UML 2.4 to support MOF 2.4). However, it was also realized that “isID” would be generally useful in UML, for the kind of purpose you indicated.
Unfortunately, the notation for this is not underlining, but, rather, adding the annotation “{id}” to the property definition. But at least it is there!
@Ed, that’s potentially good news. Do you know of plans to support composite keys? Wording of the spec implies only single-attribute identifiers are supported and there’s nothing in the Constraints section to formalise it. Thanks.
Underscoring is used in UML for static features of a classifier.
From the UML Superstructure, 2.4.1, page 70: “Static features are underlined”.
However, I agree that the underlining of identifiers, typical of some ER dialects, was easy to use and easy to spot immediately in a diagram visualization.
I share this opinion, including others semantic aspects. But you think it’s interesting to implement in a ER schema yours PhD research?
thanks you.
Not sure what you mean by “implement in a ER schema your PhD Research” but I think you can just use UML and nobody will complain about your choice