I'm developing on php at the moment, but this question should be language independent.
For DB access, I have always heard people promoting the "one class per table" practice, so I'm wondering where to put access methods that accesses 2 or more tables at the same time (using JOIN, for example). I can think of 3 ways to deal with this:
- Create a separate class for the combination of the 2 tables
- Put the access methods in the class for both tables
- Have the BLL call each db class separately and write custom logic to get what you need (i.e. do the join outside of SQL)
What is the best practice and why?
Thanks!