Reduce number of queries used
What I'm gonna ask is kinda complicated so I'll try to be as clear as possible.
I'm trying to make large system that works with "connections", so you can have items connected to each other, for example, you can have a bank of sections, and connect them as you wish to make sub-sections et so on.
So you link your sections, you can link them to one or more menus, and connect them to one or many projects. Basically, it let's you configure your data in any pratically any way you wish.
So everything is alright with the system itself, but I've come to a point where a lot of data must be recovered with many items connected with each other.
For example, if I connect a section to another section, I need to get all connections back to the menu to make sure that the menu accepts sub-sections or sub-sub-sections or any lower level section.
The challenge, is that, since anything can be connected basically anywhere, I don't know how many "levels" there are, or in other words, I don't know how much "parent items" my "child item" as, so I cannot know how to formulate my query since I don't know how many items I must get...
I don't know if I'm clear enough because a lot of details are needed to understand.
But basically, is there a way to loop or add conditions inside a query? Would there be another way then making one query to check each level since that could use a lot of queries for one verification.
Any suggestions/comments would be appreciated and don't hesitate to ask questions if you need more details...
Re: Reduce number of queries used
Possibly a better approach would be to let each individual section manage its own data requirements, if that's possible. This improves the modularity of the code and keeps the complexity of the interfaces between modules to a minimum. So when a module gets a request for data from somewhere, it sorts that out itself then squirts the answer up the tube the request came down.
|All times are GMT +5.5. The time now is 17:58.|