views:

97

answers:

3

What is the difference between Domain Model and data model?

+5  A: 

A datamodel is a design model that only describes data and it's relations. The model contains entities, but they are described in terms of what data they own not how they act on this data or what their responsibilities are.

An domain model on the other hand, is a conceptual model used in analysis of a problem domain. It describes the domain in terms of entities that have relations, data and behaviour. It describes the responsibilities of those entities as relevant for understanding the problem domain.

BTW an excelent and very short introduction to UML is:

UML Distilled: A Brief Guide to the Standard Object Modeling Language

Kdeveloper
A Data Model can exist at Conceptual, Logical and Physical levels. I consider the Conceptual Data Model to be a subset of the Domain Model and it may be the same thing (isomorphic?) in some methodologies.
MikeAinOz
+1 @MikeAinOz. Equally, a Domain Model needn't just be conceptual. The core principle in Domain Driven Design is that a real, live, fully executing Domain Model is the centrepiece of the solution.
sfinnie
+1 Was what I was going to say. I alway relate Data Model to physical and Domain to describe the problem area at an observable level (i.e., how the user see's the application in terms of items they interact with, etc).
Bryce Fischer
A: 

I think that domain model and data model are now pretty much the same with new top down modeling technologies. I mean that you can model in a class diagram and only add database stereotypes in your diagram. If you use the tool that I use then your ejb3 annotation would be immediately synchronized with your code. The next step is only to use a mapper to create your database. This technology only works with java !! Really cool :-)

See an example if you don't understand what I am talking about: http://www.forum-omondo.com/documentation_eclipseuml_2008/Eclipse_Database/Activate_JPA_Perspective/oracle_integration.html

+1  A: 

A data model is focused on the DB schema definition, including tables, columns, and relationships.

A domain model is focused on the business domain, including concepts (classes of objects), behavior (methods/logic), and relationships.

In both cases, the cardinality is used for relationships (e.g. 1:1, 1:Many, 0:Many, ...).

That said, you would ideally like the data model and domain model to be closely related, i.e. a Person with name, ... and a MailingAddress, ... relates to a PERSON table with a NAME column and a FK to a MAILING_ADDR table entry. You have to decide where logic is hosted - in the objects in the software system vs. in the DB via procedures, triggers, and such.

Mark
I fully agree with this post. My answer was dealing with an implementation trick that I use in my company. We also use this approach because we have hibernate specialists. If we didn't have this expertize I am not sure we will do the same top down modeling to database approach.