Search code examples
databaseinheritanceumlclass-diagramsingle-table-inheritance

Does the Class Diagram present the Database structure?


I am starting a whole project by myself for the first time, and I am stuck between the UML modelization ( Class diagram ) and the database structure.

Should I use the exact same classes that I model in the class diagram in the database?

For example, I have two User, the Service_provider and the Client. In the class diagram I consider each one of them as a unique class. But I chose to use single table inheritance in the database, so I store both users in the same table and add the role attribute to it.

Does my modelization stay valid in this case? or I just need one class for User? (but in this case, I can't show the relationship between the Service_provider and the Client as the Service_provider could have many Clients)

Could anyone explain this to me, please?

here are my thoughts for the class diagram


Solution

  • The development of an app is supported by an entire set of (evolving) models, as illustrated in the diagram below.

    The three main purposes of making UML class models when developing an app are:

    1. Describing the entity types of the app's problem domain for analyzing and better understanding the requirements for the app in a conceptual (domain) model.
    2. Designing the schema of the app's underlying database (this is typically an RDB schema defined with a bunch of CREATE TABLE statements).
    3. Designing the model classes of the data model of your app, which will be coded, e.g., as Java Entity classes or C# classes with EF annotations.

    For 1 and 2, you may take a look at my book An introduction to information modeling and databases, while for 3 you may check out a book on model-based development, e.g. for Java Backend Apps or JavaScript Frontend Apps.

    enter image description here