#1 2020-06-06 20:16:59

Javierus
Member
Registered: 2019-09-18
Posts: 55

Totally Newbie question on SQL and mORMot

In mORMot, do you use triggers and all other SQL stuff, or you should do it in Delphi?
I'm not asking if you can do it, but if you are expected to do it

Offline

#2 2020-06-06 20:54:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Totally Newbie question on SQL and mORMot

I try to implement persistence agnoticism, and one way of doing it  is to put the logic not in DB but in code.
So triggers and such are not in SQL/ORM, but in code.

The notion of "Aggregate" is the key for that. It breaks the relational model by duplicating the data into each use context, with enough data for each context.
Then if you have to synch information between the contexts, I would use the notion of "events", then spread them using a publish/subscribe mechanism: each context will subscribe to the data change from other contexts, and react in its own database.
Our interface callabacks feature in SOA is the best way of doing it. It could be pretty efficient. Each context is its own Micro-Service, with its own local storage (mainly SQLite3).
As a result, the DB is not the center any more. There are several DB, which just reflect the data at a given state, sometimes all states of data (in an event-driven design).

In a nutshell: I don't create any trigger, ever, in DB.
As a side effect, it eases testing and maintenance, and it also allow to use NoSQL storage if needed (or if it is more efficient).

Offline

#3 2020-06-08 21:39:56

Javierus
Member
Registered: 2019-09-18
Posts: 55

Re: Totally Newbie question on SQL and mORMot

Thank you very much; that has helped me a lot

Offline

Board footer

Powered by FluxBB