Home > database >  DDD - Single table for images or separate one for each bounded context?
DDD - Single table for images or separate one for each bounded context?

Time:11-16

Currently, I have a single table for images in my app that saves the content for other entities and they are related. In DDD should there be a separate bounded context for images with their own database and image processing? Or should every bounded context have Image maybe as value object and field? I'm thinking maybe later on you want a microservice only for image handling? But then won't that make it hard to work with communication since many relations exist since many entities might have images?

CodePudding user response:

Don't be afraid of duplication - only issue with it is when it comes to sync changed data between contexts.

Image more or less in 90% is a value object (or rather image meta-data, like size, name, etc.)

I presume, that different contexts in your app uses different parts of this image object - one needs names, other needs names and dimensions, etc.

You can keep only the needed data duplicated for each context and when time comes - you could use a synchronisation event to update this image object data in all contexts.

More can be found also here.

  • Related