This is something that has intrigued me a lot recently. It's a general SQL/Relational Database problem coming from a guy who prefers Mongo.
What I want is, to, as such, associate data from different tables in the most efficient, easiest way, without using associations and assuming I can't restructure or re-model the db.
So, for example, with FQL (which doesn't have associations), if I asked for the name
and eid
of all the events my current user has been invited to, I'd also like to know whether my current user is going, but that info is in the 'event_member' table.
In this instance I've an interest in another column (rsvp_status
) in event_member
, one that I'd like to be associated with the columns from event
, i.e eid
and name
.
In this case the instinct may be to say that since every event has a name
, an eid
and a rsvp_status
then we could say sort by eid
and then match each nth item (for n=1 to whatever), because there's guaranteed to be the same number, but there are many cases when we can't do that.
And I know I could do separate queries and then iterate through and match them by eid
, but basically I'm looking for a generic, simple,efficient solution for the associations idea if one exists. Preferably in javascript.