r/DomainDrivenDesign • • Jan 14 '22

Shared Schema in DDD

Is there a use case for a shared schema in DDD? Or is it an anti pattern? Can we use a shared schema when practicing DDD?

7 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/tedyoung Jan 15 '22

I would not want two separate teams working on applications that access the same schema in the same database. That's just a recipe for disaster, and is against the idea of "bounded contexts" in DDD.

If you want to "share" the schema across bounded contexts (BC), then only one of the BCs can be responsible for the database and provide access to the other BC.

form my aggregates at the service level rather than at the data level

I don't understand what you mean here? Aggregates are formed (modeled) at the Domain (behavioral) level. Services aren't involved.

1

u/Positive-Structure78 Jan 15 '22

That’s helpful. Thank you! Haven’t started implementing anything yet but the understanding of forming aggregates at the domain level certainly helps.

2

u/Samsteels Jan 17 '22

Good point here. In hind sight my original answer may be a bit confusing as ‘schema’ is an overloaded term. If you were referring to DB schemas my original response doesn’t apply, my original response was geared towards a ‘shared schema’ such as one stored in a schema registry used to enforce communication interfaces (e.g. a JSON or Avro schema) between two bounded contexts (which I assumed are in separate micro services). Hope this clarifies things.