I'm working with DAO pattern in PHP. I understand the benefits that you get from separating your model this way, but what I don't understand is how are you supposed to build DAOs and VOs when your tables are related through associative entity
I'll give an example:
In my DB I have
USERS(id,username);
USERS_POSTS(id_user(FK),id_post(FK));
POSTS(id, title);
USER_COMMENTS(id_user(Fk),id_post(FK));
COMMENTS(id, text);
I create UserVO, PostVO with corresponding setters and getters and then UserDAO and PostDAO in charge of SQLs that in the end return VOs . Performing CRUD operations on data from these tables is really simple, but when you start thinking about relating tables and retrieving data that's across different tables is when you start thinking that using DAO is not that simple any more...
How would you organize your DAO pattern if you wanted to return all the comments made by the author of article? I don't need SQL query I'm just giving this as an example of real situation...
I read that it would be a good idea to have associative DAO and Vo for every associative table. What would its VO consist of? Just 2 foreign keys or from all attributes from both tables?
If the logic is having DAO and VO for associative entity what's the solutions if the query goes "through" more than 3 tables (using 2 associative entities)?
I doubt that DAO pattern would have object called users_posts_comments_article :)))
Thanks