[SQLObject] How to store attributes of relationships?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Edmund L. <el...@in...> - 2003-06-01 06:46:17
|
It's boring me again. I've come across a conundrum... how to store attributes of a relationship. Here's the problem... Suppose you have two entities: Person and Dog. You want to be able to model the fact that there is a relationship between any person and any dog. The way it would be done with SQLObject, I suppose, would be to use RelatedJoin as per: class Person(SQLObject): _columns = [ "name"] _joins = [RelatedJoin("Dog")] class Dog(SQLObject): _columns = [ "name"] _joins = [RelatedJoin("Person")] When RelatedJoins are used, the relationship is stored as a row in a mapping table named Dog_Person. So far so good, this is how it is done in a traditional schema too. Now the problem is that relationships have attributes too. For example, we might want to store the date relationship started, intensity, etc. These are attributes of the relationship, not of Person or Dog. In traditional schema, this would be stored in the mapping table, or some table that is related to the mapping table. How do we deal with this in SQLObject? ...Edmund. |