Many-to-Many relationship issue (ALL subquery?)

thread: 5 messages  |  last: about 6 months ago  |  started: wednesday, march 10, 2010, 12:38 pm pst


#1  |  phredphish (Brooklyn, NY) United States of America
Wednesday, March 10, 2010, 12:38 PM PST

Basic layout

Resource
IdResource
Name

Keyword
IdKeyword
Name

There is a many-to-many association table connecting the two.

Problem:
The keywords are used as filters. A user can select any number of keywords and it should filter the results such that each resource has ALL of the keywords selected associated (and any others not selected - the important point is that all that are selected are associated).

I can implement in PHP manipulating arrays ... but that's really slow when dealing with thousands of resources.

I essentially want to do:
QQ::In_All(QQN::Resource()->Keyword->Keyword->IdKeyword, $arrSelectedKeywords) ... something like an SQL subquery with the ALL operator such that it will “return TRUE if the comparison is TRUE for ALL of the values in the column that the subquery returns.”

Any ideas? It's probably really simple - I'm just a bit perplexed.

Thanks,
Andrew

#2  |  VexedPanda (Calgary, AB) Canada
Wednesday, March 10, 2010, 2:39 PM PST

Answered with solution in QCubed forums:
http://qcu.be/content/many-many-relationship-problem-all-subquery#comment-4461

#3  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Wednesday, March 10, 2010, 9:43 PM PST

Cool deals -- if you check out Issue #42 you'll see we're starting to get some traction on some improvements to the QQ layer.  Once the current dev release cycle gets pushed to stable I'm pretty sure these movements will start accelerating a bit.

It looks like you and folks at qcubed have thought through some stuff as well, I'd love any input (either higher level suggestions or even lower level code contributions, if you have them) that you'd be willing to provide.

#4  |  VexedPanda (Calgary, AB) Canada
Thursday, March 11, 2010, 8:33 AM PST

Well, I guess you've already seen http://trac.qcu.be/projects/qcubed/attachment/ticket/321/ticket321o2.patch :)
It's a pretty simple change, but has powerful results, as you can see. :)

#5  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Friday, March 12, 2010, 10:12 AM PST

Thanks!  Yeah, it probably makes sense to get this in, along with a lot of the other QQ changes that have been discussed, right after we get the next stable out, which should hopefully be 0.4.14 within the next day or so.



Copyright © 2005 - 2010, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.