Why are we so often making the database the foundation of our architecture and not the domain logic? Because we feel more comfortable with the database than with the domain logic. We need to leave the comfort zone!
13
3
38
The relational model along with normalisation principles is a very robust way to model your domain. If you do it right, all your logic will just fall into place. You want to leave this "comfort zone"? Why? Are you sure you were doing it right in the first place?
6
4
45
That may be possible and even desirable for some domains. But I struggle to think of a project in my experience that did not end up as a mess of database concerns mixed with domain concerns when we used the database model as the domain model.
1
1
And I struggle to think of a clean line where you can actually separate those concerns. How are they different? How is the relational model not just your domain model? What would be some specific examples of where such a mess is inevitable?
2
4
It already starts with an applications usually joining the same set of tables at runtime to provide answers to business question. Separate tables provide alleged flexibility that is not only mostly not needed but imposes nothing but technical complexity.
1
2
Write a view for those joins. Or better. Write a function that composes your jOOQ joins dynamically for greater re-use.
2
If I can create an Order class that holds a list of LineItems and I can impose a minimum order amount rule over that list, I can write a unit test for that that needs nothing but Java and a ms to execute. Why should I complicate that?
1
Well, are you going to store it or not? If not, as you so eloquently put: en.wikipedia.org/wiki/Straw_…
1
1
Yes. But thats my point: why would you conflate the two? You argued separation of concerns yourself, didn’t you? You asked for a reason why one’d not use the relation model as primary. One answer: because it’s simpler to use a different one, not tied to a storage technology.
2
2
Admittedly, you could argue it would be even better to specify everything in a meta language, e.g. some kind of DSL, so that you’re not tied to Java

Jan 28, 2021 · 11:45 AM UTC

2
Sure, if you’re in a context where building DSLs is (economically) feasible. For mere mortals, it boils down to some arbitrary, general purpose programming language.
1
I’m not seriously suggesting that. I’m merely pointing out that you see no problem with a dependency on Java/the JVM, but do with one on SQL/an RDBMS.
1
1
Oh, oh, oh, I know a DSL just for that! CREATE TABLE ... 😉
1