From chart diagram to database relational chart

Can you advise me a tutorial or book to convert a class diagram to a relational database diagram. and vice versa, if such a link exists, send it.

+8
database class relational-database uml
source share
5 answers

A class diagram is a system using an object model. A relational database diagram is a data system using a relational model. There are significant differences between the way these two models will represent the same system. And the data model does not model behavior. It models only data.

However, there is a modeling system that is halfway between the class diagram and the relational diagram. It is called an ER chart, where ER is short for Entity-Relationship. In the ER model, an entire subject is analyzed for “entities,” which can be people, places, or things that have a personality. They can even be intangible things like a bank account. Relationships relate to two or more entities and its statements about the relationships that make up most of the data in the database. Data values ​​are instances of attributes, and attributes describe either entities or relationships between objects.

Most of the ER charts that you see in SO are really relational charts, masquerading as ER charts. In this ER diagram, foreign keys are missing, many-to-many relationships can be displayed as a single line, and things like gene-spec patterns look the same as in class diagrams. If fact, the ER diagram can be considered as a projection of the object world only onto the data world.

If you study ER modeling as a separate activity from relational modeling, as a result of getting a different model, it will be easy for you to convert class diagrams to ER diagrams.

Hence the transformation of ER diagrams into relational diagrams is almost mechanical. Each object gets a table, many-to-many relationships get their own table. Inheritance and association receive special treatment and so on. Relations, which were considered abstractions in the world of ER modeling, materialized as foreign keys. The primary key of each table becomes apparent in terms of the key attributes of the objects in the ER model.

And the so-called attributes in the ER model (possibly “properties” in the class model) become “columns” in the relational model.

there are some fancy tools that manage object models, ER models, and relational models in the same tool and can move between these models for you. One of them, the Data Architect, was very good, but very expensive a few years ago.

+3
source share

Not sure what you mean by “relational database diagram”. If you are referencing a SQL script with DDL suggestions for creating a relational schema for your model, then maybe you can just see how the tools do this conversion (for example, check out this online UML SQL code generator http: // modeling-languages .com / content / uml2db-full-code-generation-sql-scripts-databases )

Most conversion rules are simple (class-> table, attribute → column, association → foreign key, ...), but you can play with UML diagrams with inheritance and association classes and see how this translates.

+3
source share

Another option I'm using is to add database stereotypes to the class diagram. It generates a Java save annotation in my code. Finally, I generate code from Java code using Hibernate.

It works very well.

+2
source share

There is an excellent article that explains this transformation: Database Modeling in UML

+2
source share

Using Enterprise Architect , you can automatically generate your modal modalities in a relational database model using your MDA (Model Driven Architecture) Transformations. This eliminates the need to repeat all your charts manually.

Learn more about MDA Transformations.

+1
source share

All Articles