I'm working on an API and I always seem to run into this thought debate. When designing the code structure that interacts with the database (repositories, data providers ect..) how do I structure the repositories based on hierarchical relations?
For example I have an app with Items and those items have images. Do I make one repository with CRUD operations for both the images and the items or do I make two?
I usually ask myself "well how am I going to be modifying the data?" and it usually makes sense to do one repository for business reasons. I'm always going to add an image in relation to an item. However if I want to have something like an administrator UI backing it, anything goes, as all of the sudden those tables are now almost modifiable as if they are their own entities. The relationship still holds true but I would want to do something like Get All Images or remove this image because it's offensive.
The goal is to try and make the code structure make sense and be the most useable.