db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schmitt" <mi.schm...@gmx.de>
Subject Re: foreign-key: how to reference two fields?
Date Tue, 15 Apr 2003 20:21:22 GMT
Hi,
> 
> Please let me know how you get this to work. When I tried a composite 
> primary key like that, the generated om would not compile.
> 

I just declared the referenced table like that:

  <table name="city" idMethod="none">
    <column      name="name"
                 required="true"
                 type="VARCHAR"
                 size="255"
                 primaryKey="true"/>
    <column      name="country_name"
                 required="true"
                 type="VARCHAR"
                 size="100"
                 primaryKey="true"/>
                 
    ... [some more columns] ...
  </table>
  
  Both columns, 'name' and 'country_name', are declared as primary key.
  My referencing table looks like that:
  
  <table name="band">
      <column name="id"
              required="true"
              type="INTEGER"
              primaryKey="true"/>
      <column name="name"
              required="true"
              type="VARCHAR"
              size="255"/>
      <column name="origin_city"
              required="true"
              type="VARCHAR" 
              size="255"/>
      <column name="origin_country" 
              required="true" 
              type="VARCHAR"  
              size="255"/>
              
      <foreign-key foreignTable="city">
        <reference local="origin_city"     foreign="name"/>
        <reference local="origin_country"  foreign="country_name"/>
      </foreign-key>
    </table>
  
  If I generate code for that compilation is no problem and both
  values ('origin_city' and 'origin_country') will be used to get
  the referenced city.
  
  bye,
  michael



Mime
View raw message