skip to Main Content

Just wanted to make sure that I’m understanding this right:

  • designing UML-diagram we are talking about the relations between entities?
  • in the context of SQL a table is a relation?

I can remember that my teacher, for a while ago, was talking about associations between entities which makes me unsure what words are the right way to use in the context of UML-diagrams and SQL.

Words to figure out: entity, relation and association. Contexts: UML and SQL.

2

Answers


  1. First, let me start that there is a lot of confusion in the question. There are some terms that are not used in the UML context. So it is critical to build understanding on that.
    The answer would have to be too broad for the StackOverflow but let me give a couple of directions that should be sufficient.

    First of all, the terminology has to be properly corrected. In UML we do not have a term Entity. We have Elements that are constituents of the model. The Elements are then divided (among others) into Classifiers and Relationships. The Classifiers, while broader than what we typically understand under Entity in the SQL context is a good approximation. The most commonly used type of Classifier is a Class. In most cases an Entity in ERD diagram will be represented by a Class in the UML Class diagram.

    Relationships are showing how the Elements are related with each other (note, a Relationship is also an Element). While there are several types of Relationships, the most broad type of the Relationship between Classifiers (and Classes for instance) is a Dependency. This Relationship type shows only, that one Classifier requires the other to function. A more precise Relationship that is semantically stronger than a Dependency is Association. In SQL terms only some Associations are significant, and those are typically represented as Foreign Key Constraints.

    I’d say you should go back to reading the Applied UML and Patterns. It is all explained there, with examples. Focus on UML first and ignore the SQL part. Once you get a grasp of it, get back to the relation to SQL.

    Login or Signup to reply.
  2. In UML we have classes and associations. There is no entity in the UML specifications, although a popular class stereotype is «entity»:

    an entity represents long-lived information relevant for the stakeholders

    which, in other words, generally refer to a set of presistant domain object stored in a database.

    In SQL databases, we have tables. Tables represent what is called a relation in relational algebra. Now database modellers have invented the term of entity that corresponds to a set of relations, and relationships that correspond to a mapping between entities.

    So you mix in your question very different concepts. However, there are some similarities: relational entities correspond to a subset of simple classes without behaviours, and relationships correspond to associations. The field that maps the relational world with classes is called object-relational mapping (ORM). ORM is a set of techniques that allow to map classes of objects to database tables and associations to relationships, and vice-versa.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search