davidm | 26 Jun 05:37
Favicon

metakit relational questions


Hi,

I worked out how to do nested views (from trawling through list
archives, it isn't mentioned in the python documentation) - this is
great for emulating a simple SQL join.

But how do you do two tables that relate to each other?

For example, imagine one table called 'Director' which has the
columns:
 - name (string)
 - age (int)
 - companies (related join to Company)

and another table called 'Company', which has the columns:
 - name (string)
 - directors (related join to Person)

The situation is that each person, represented by a row in Director,
could be a director of more than one company, and each company would
often have two or more directors.

I'm familiar with SQLObject, where this can be very easily
accomplished with 'RelatedJoin' column types.

But is there a way to do this in Metakit? For example, given a person,
look up the list of companies of which s/he is a director, and for a
company, look up the list of directors?

The obvious way would be to have flat tables for Person and Director,
and a third table called 'Directorship' with the columns:
 - director_id (int)
 - company_id (int)

Then given a person, I could do a select on Directorship for rows
containing that person's id, then for each company ID found from that
select, I could do another select on Company for rows containing that
company ID.

But is there a faster, less manual and higher-level way to do this?

Thanks in advance

Cheers
David

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "metakit" group.
To post to this group, send email to metakit <at> googlegroups.com
To unsubscribe from this group, send email to metakit-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/metakit?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane