A relationship and its inverse relationship (when defined) define an association. If a relationship has no inverse, the corresponding association is said to be uni-directional, otherwise it is bi-directional. Associations can be of the three kinds, with the following constraints:
+--------+ +--------+ | Writer | | Book | +--------+ +--------+ | ..... | | ..... | | toBooks|<-------->>|toAuthor| +--------+ +--------+
id(see 2.6.1). The
idwill use the python type
intand the SQL type
FK_Writer_id, which is not a class property and is mapped to the python type 'int' and the SQL type
idto the destination entity Book 's foreign key
FK_Writer_id, with a multiplicity's upper bound , say,
FK_Writer_idto the Writer 's primary key
Writer.id, with a multiplicity's upper bound equal to 1.
You may want to specify an other inverse relationship than the one calculated by the framework. (Note that when working with the ZModelizationTool, it shows you the inverse relationship it finds for a given relationship when in the Entity's global view. If the inverse relationship is not found or is wrong, first check that the relationships are correctly defined.)
The way an inverse relationship is calculated is simple: the framework looks at the destination entity and searches for a relationship whose joins have source and destination attributes corresponding one-to-one to the destination and source attributes in the original relationship's joins. And if this is not clear, look at the example above (step-by-step procedure to build a one-to-many association): toBooks is the inverse relationship for toAuthor and conversely, as expected.
If, however, the framework is not able to find the correct inverse relationship, you can force it to use you own point of view; for a complete description of how this can be done, refer to CustomObject.inverseForRelationshipKey() documentation string.
Comments are welcome: Sebastien Bigaret / Modeling Home Page