Hi guys,
I've been crawling this forum to find a reasonable explanation but failed doing so (might also because my query skills suck, in that case forgive me).
We're having an internal discussion here about aggregate roots and the usage of foreign keys.
Basically, what I understood is that aggregates are designed according to your transactional requirements.
Assuming:
- we have an aggregate A and another aggregate B
- assume A and B share a 1 to many relationship.
- B refers to A by using it's identifier (so not the full object) because of the aggregate / eventual consistency definition.
- We use an RDBMS to store A and B where each have their own table
- B has a column referring to an identifier A.
My big question is: Is it wise to put a FK constraint in the RDBMS between B and A? It feels like breaking the aggregate / eventual consistency rule. But what I really want to know is what the problem would be if we would introduce the FK in the database. Or am I completely mishitting the ball and is that FK allowed and even preferred.
Thanks!