|
Is it correct to show the database table in class? I have a class diagram that has objects that save records to a database. So i don't know whether i should show the database table in the class diagram or not. If not allowed then how can I show the relationship between the object and a database? That is how do map objects to a database?
|
|
|
|
|
Qobacha wrote: So i don't know whether i should show the database table in the class diagram or not.
Probably not. Instead you would have a object data model diagram.
However if the project is small enough such that there is only one or two diagrams and only a couple of tables then yes that is ok. However you need to make it clear that that they are data objects rather than class objects.
|
|
|
|
|
You seem to be describing Table Data Gateway pattern (Fowler, Patterns of Enterprise Application Architecture). This class inserts or updates records in a particular table. The convention is to name the class after that table. e.g. The class that updates rows in User table is called UserGateway (or simply User).
Hence, the association between the class (which contains code in C++/C#/Java language to update the table) and the table is described by the name itself. There is no need to explicity show the relationship.
However, there is no restriction to show tables in a class diagram. For example, you may want to describe database schema in UML. All you need is to create a new stereotype, e.g. <>. This stereotyped class can then represent database tables.
|
|
|
|