I would suggest a slightly more flexible interpretation of this pattern. You do not have to feel limited or make strange decisions in order to be 100% compatible with the definition of patter.
Please do not get me wrong. I do not suggest throwing patterns. I actually suggest using them appropriately.
Answering your question:
- If there are not many interdependencies between your
ChoiceGateway and QuestionGateway , it is normal if they are separated. - If there are interdependencies, and it is better that these tables "join" in terms of business logic, you can create something like a "view", for example, call it
QuiestionView . Thus, your business logic may be a little more understandable, and all specific DB files will be encapsulated in a specific view.
Basically, it's all about useful abstractions. If you are comfortable working with these tables, independently define independent gateways with some possible duplication. If you need "all in one place", just define a high-level abstraction.
By the way, the template itself is abstract not only for tables, but also for viewing. Therefore, I see no reason why you cannot create a higher level abstraction using a specific approach.
The table data gateway contains all the SQL to access a single table or view
source share