My question is about what should be go first in software developing: database model or domain model? Or these notion are parallels? Thanks.
It depends on whether you're a database or an object person. Each one would claim supremacy and say that their specialty should be done first.
I'd disagree with both. The first thing you should do is understand your problem well. The model and schema will flow from that.
You can't get rid of the object-relational mismatch impedence, no matter what you do. Objects are instance-based; SQL is set-based. You'll still have the problem.
What should come first is the conceptual design (describing the problem domain in terms comfortable to the stakeholders), and the model is a logical design based on the conceptual design. There is a reasonably comprehensive set of tools and techniques for deriving an object model from the conceptual requirements. There are few commonly familiar tools and techniques for mapping from concept to schema design. (The only one I'm familiar with, which is a good one, is Object Role Modeling.) However, there good ways to use an object model to develop a schema. So I prefer conceptual to object model to data model.
Another way to view the question is that if you develop a database then the application tends to turn users into data collection agents serving the data model, losing the value of good requirements based on user stories and use cases (the second of which seem to turn into CRUD.)
Note: confusingly, ORM (Object Role Modeling is unrelated to ORM (Object Relational Mapping).
Design good database and object models and leverage an object-relational-mapping (ORM) layer to solve the impedance mismatch (that's what they are designed to do).
The answer will greatly depend on type of application you are developing and the languages/framworks you are using. If you will be writing lot of business logic in database (like Stored Procs, Views, triggers) then it makes sense to first design the database. If you are going to use some frameworks that map domain model to database (and possibly schema generation, like hibernate) then you will like to write Domain classes first.
This blood feud is older than pirates vs. ninjas. :)
In my opinion, and it is just that, starting at the domain model first helps to bridge that gap between the functional requirements and the technical design. The object model better represents the business data than a data model can, and they can be diagramed for better understanding by non-technical business analysts and project managers early in the project.
Pirates! Ninjas! Chicken! Egg!
Every project is different, and sometimes, the design of your database determines the success of your mission. It's quite rare, these days, because hardware and software has moved on - but if you have to store and compute huge volumes Of data, the schema may be one of your key concerns.
Most Of the time, the challenge is the business domain. I recommend "domain driven design" by Evans on that topic - but I'd encourage you to capture the business domain first, using use cases or user stories; turning those into software is the key challenge, and if you and your colleagues think best in entity relationships, go for it; if you're mOre comfortable with class hierarchies and responsibility diagrams, that's cool too.
My impression is that the industry is moving to objects, rather than tables - career-wise, that might be the way to go.
The domain model presents a higher level of abstraction than that of the database model. The database model, on the other hand, adds a number of concepts that are harder to directly map to business concepts (e.g. pivot tables, foreign keys, views, etc). If you start by the database model you'll find yourself making a greater number of constraining decisions as opposed to starting with the domain model.
© 2022 - 2024 — McMap. All rights reserved.