How to generate Relational Model from UML Class Model?
Asked Answered
M

3

5

Does anyone know an application (Enterprise Architect, ...) that allows mapping from UML Class Model to Database Relational Model automatically? How?

Thanks

Misspell answered 23/3, 2011 at 14:14 Comment(0)
D
13

Further to what the others have said, Enterprise Architect supports model transformations from UML class models to Database relational models. It does this automatically.

To do this, right click on the package that contains your Class Model and select "Transform Current Package" [Ctrl + Shift + H]. Select DDL as your transformation and give it a Target Package (by clicking the [...] button.

Once you hit the go button Enterprise Architect will perform the translation which will give you the Relationship model. You will now be able to set your desired database language and use Enterprise Archtiect's code generation feature to generate the SQL scrips needed to setup the DB.

I hope this helps!

Darceydarci answered 24/3, 2011 at 1:45 Comment(0)
P
1

Enterprise Architect and myriad other tools will allow you to generate DDL from UML models. (Note: you'll need to pick a version that supports "Database Engineering" - see here for EA).

'How' is pretty simple. Classes become tables, attributes become columns, relationships become Foreign Keys. You can denote other properties too (e.g. Primary/Unique key) using stereotypes/constraints. (Can't quite remember, it's been a while).

Pretty much any tool that supports database design will use the same approach. There are differences at the fringes (e.g. some tools support round trip, some only generation). But it's largely the same story.

Palimpsest answered 23/3, 2011 at 14:37 Comment(2)
Not every class need to be a relation.Fiddlehead
@overexchange: true. Not all classes will have data (members) that need persisted. Indeed, there's a good argument that mapping classes-> tables (relations) is fundamentally incorrect. However it's still by far the most common approach.Palimpsest
C
1

If by relational model you mean a real model, then some tools (like MagicDraw) offer a profile that can be used to annotate the UML class diagram with stereotypes like <<pk>>, <<fk>>, <<table>> to represent a relational model.

However if what you are looking for is to generate a SQL script with the tables, columns,... corresponding to your UML class diagram, then you have plenty of options. If your tool does not include this option you can try this online UMLtoSQL generator (there´s a free option for doing tests and learning about how the transformation is done): http://modeling-languages.com/content/uml2db-full-code-generation-sql-scripts-databases

Circuity answered 23/3, 2011 at 19:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.