Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv20492/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Documented PyModel RToOne / RToMany
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** DefiningaModel.tex 30 Aug 2003 14:07:11 -0000 1.29
--- DefiningaModel.tex 30 Aug 2003 14:42:33 -0000 1.30
***************
*** 1073,1089 ****
cf.\ref{pymodel-relationship-props})
! Minimally, a \class{RToOne]} needs a \code{name} and a the name of the
destination entity, \code{destination}.
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied:
\begin{itemize}
! \item \code{src}
! \item \code{dst}
\end{itemize}
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
--- 1073,1122 ----
cf.\ref{pymodel-relationship-props})
! Minimally, a \class{RToOne} needs a \code{name} and a the name of the
destination entity, \code{destination}.
+ \paragraph{Source and destination attributes}
+
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied:
\begin{itemize}
! \item \code{dst} is the primary key of the destination entity identified by
! its name in attribute \code{destination}.
! \item \code{src} is calculated from the destination entity's name stored in
! the relationship's \code{destination } attribute. It is a string like:
! \code{'fk<sourceEntityName>'}, possibly followed by a integer (such as in
! \code{'fkEmployee1'}) if the name already exists in the destination entity. In
! fact, a PyModel does more than just computing a name: it also automatically
! creates the corresponding foreign key in the source entity.
!
! For example, a pymodel containing:
! \begin{verbatim}
! self.model.entities = [
! Entity('Employee',
! properties=[ RToOne('toStore', 'Store'),
! # ...
! ]
! \end{verbatim}
!
! automatically binds \code{dst} to the destination entity \code{'Store'}~'s
! primary key, and creates a \code{AForeignKey} named \code{'fkStore'} in the
! source entity \code{'Employee'} (unless such a property --either an attribute
! or a relationship-- already exists with this name, in which case it uses the
! first unused name among \code{'fkStore1'}, \code{'fkStore2'}, etc.
!
! Last, the \code{'inverse'} field of a \class{RToOne} (which designates the
! inverse relationship defined in the destination entity) has some effect in the
! automatic generation of \class{AForeignKey}: please refer to
! \ref{pymodel-relationship-props-inverse} for a full discussion on this topic.
\end{itemize}
+ Of course, you can specify your own source and destination attributes. In this
+ case, it is requires that both are supplied, and that they corrspond to
+ attributes (resp. \code{AForeignKey} and \code{APrimaryKey} attributes)
+ explicitly declared in the source/destination entities.
+
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
***************
*** 1103,1106 ****
--- 1136,1175 ----
(All other defaults are \class{BaseRelationship}'s ones,
cf.\ref{pymodel-relationship-props})
+
+ Minimally, a \class{RToMany} needs a \code{name} and a the name of the
+ destination entity, \code{destination}.
+
+ \paragraph{Source and destination attributes}
+
+ Attributes \code{src} and \code{dst}, identifying source and destination
+ attributes, are automatically calculated if they are not supplied. The rules
+ are the same than the ones given in~\ref{pymodel-relationship-props-toone},
+ you just need to swap name \code{'src'} and \code{'dst'} in the above
+ explanation.
+
+ As an example, suppose you have a pymodel declaring such a \code{RToMany}:
+ \begin{verbatim}
+ self.model.entities = [
+ Entity('Store',
+ properties=[RToMany('toEmployees','Employee')]
+ ),
+ # ...
+ ]
+ \end{verbatim}
+
+ \class{RToMany} then automatically binds \code{'src'} to the source entity
+ \code{'Store'}~'s primary key, and creates a \code{AForeignKey} named
+ \code{'fkStore'} in the destination entity \code{'Employee'} (unless such a
+ property --either an attribute or a relationship-- already exists with this
+ name, in which case it uses the first unused name among \code{'fkStore1'},
+ \code{'fkStore2'}, etc.
+
+ You'll also want to read the section \ref{pymodel-relationship-props-inverse}
+ for a complete explanation on how automatic binding/generation of
+ \class{APrimaryKey}/\class{AForeignKey} is handled when two relationships are
+ inverse of each other.
+
+ \subsubsection{Inverse relationship\label{pymodel-relationship-props-inverse}}
+
|