A
A
Alex2015-12-11 02:49:30
Database
Alex, 2015-12-11 02:49:30

Should the domain model match the database in structure?

The question arose while studying development approaches with the Entity Framework (Database first, Model first). The impression was that the subject model (with its classes, properties) is a complete reflection of the database (with the corresponding tables, fields). Is the domain model always identical to the database in its structure? Please explain with a specific example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2015-12-11
@dmitryKovalskiy

Well nobody canceled normalization of a DB yet. The bottom line is that it may or may not be identical. A simple example. Suppose you have a certain entity that can be in a number of states. The states are described by lines like "Waiting", "Here", "Already late". Most likely your Subject Model describes this parameter as a string, but the database will be represented as some kind of identifier on a third-party table with a list of states. Another example. You have an entity that is described by a set of properties. These properties are stored as follows: there is a table - a standardized list of properties and there are 2 more tables - one stores "typical" values, and the other "individual". Next comes the magical request, which generates a propertyName-value table and does a PIVOT turning the table into a string. Here, it will not work to compare what is in the database with your subject area under pain of death. It turned out quite confusing, I hope my colleagues will correct the flaws in my examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question