I have developed a structure to represent hierarchical data in in my db. Now I have 3 tables with relationship defined with each one.
How should I query my db to get the data in such a structure.
Query I have to get data from separate tables (Gives me all the users with product in the table) List discUsersConfs = newArrayList(ao.find(DiscUserConf.class, Query.select()));
(Gives me all the effects with users in the table)
List discEffectConfs = newArrayList(ao.find(DiscEffectConf.class, Query.select()));
How can I combine these queries to get the data in way I have shown the relationship in the below image. I am using Active Objects which is one of the ORM.
答案 0 :(得分:1)
我通常会这样做。
select all from table1
while fetching{
select again but from table 2 where user = (user from the table1)
...and so on..
}
这是一个问题,它有多个解决方案。我的方法的问题是,对于每个更深层次,您必须提供更多表并手动将它们添加到代码