Re: Relationship between tables

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Mar 12 2005 - 00:19:49 EST

  • Next message: Andrus Adamchik: "Re: open cayenne project error"

    Sami,

     From the first glance this looks ok to me... One thing I noticed is
    that a relationship from employee to department is missing. Did you
    delete it manually? I suggest you add it back. In XML it will look like
    this:

    <obj-relationship name="toDept" source="Emp" target="Dept"
    deleteRule="Nullify" db-relationship-path="toDept"/>

    Cheers,
    Andrus

    On Mar 11, 2005, at 4:14 PM, Sami Mohammed wrote:

    > Hi
    >
    > I have 2 tabel emp and dept(Master).
    > emp has foregin key (deptno).
    >
    > see tables below
    >
    > Dept Table :
    > -------------------------------
    > deptno number primary key
    > dname varchar2
    > loc varchar2
    > --------------------------------
    >
    >
    > emp table:
    > ------------------------------
    > empno number primary key
    > ename varchar,
    > salary number,
    > job varchar,
    > deptNo --> Foreign key reffering to dept tabel.
    > ------------------------------------------------------
    > when i renginering cayenne developed the follwing code. is this
    > correct or i have to do manually for the reletionship in the cayenne
    > modeler.
    > pls let me know.
    >
    > <db-entity name="EMP" schema="MySchema">
    > <db-attribute name="DEPTNO" type="INTEGER" length="22"/>
    > <db-attribute name="EMPNO" type="INTEGER" isPrimaryKey="true"
    > isMandatory="true" length="22"/>
    > <db-attribute name="ENAME" type="VARCHAR" length="50"/>
    > <db-attribute name="JOB" type="VARCHAR" length="50"/>
    > <db-attribute name="SALARY" type="INTEGER" length="22"/>
    > </db-entity>
    >
    >
    > <db-entity name="DEPT" schema="MySchema">
    > <db-attribute name="DEPTNO" type="INTEGER" isPrimaryKey="true"
    > isMandatory="true" length="22"/>
    > <db-attribute name="DNAME" type="VARCHAR" length="50"/>
    > <db-attribute name="LOC" type="VARCHAR" length="50"/>
    > </db-entity>
    >
    >
    > <db-relationship name="empArray" source="DEPT" target="EMP"
    > toMany="true">
    > <db-attribute-pair source="DEPTNO" target="DEPTNO"/>
    > </db-relationship>
    > <db-relationship name="toDept" source="EMP" target="DEPT"
    > toMany="false">
    > <db-attribute-pair source="DEPTNO" target="DEPTNO"/>
    > </db-relationship>
    > <obj-relationship name="empArray" source="Dept" target="Emp"
    > deleteRule="Cascade" db-relationship-path="empArray"/>



    This archive was generated by hypermail 2.0.0 : Sat Mar 12 2005 - 00:19:53 EST