db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Problems with VARCHAR primaryKey
Date Tue, 02 Sep 2003 23:14:04 GMT
Chris Huisman wrote:

> If I change the table definition to be:
>    <table name="ALTERNATE_NAME" description="Alternate names" 
> idMethod="none">
>        <column name="ALTERNATE_NAME" primaryKey="true" required="true" 
> type="VARCHAR" size="50"/>
>        <column name="COMPOUND_ID" required="true" 
> type="INTEGER"/>              <foreign-key foreignTable="COMPOUND" 
> onDelete="cascade">
>            <reference local="COMPOUND_ID" foreign="UID"/>
>        </foreign-key>
>    </table>
> I am able to add as many "ALTERNATE_NAME" rows as I want, but I cannot 
> udate the ALTERNATE_NAME.alternate_name column.
> How should I go about doing this?  Are you allowed to update primary 
> keys using torque and MySQL??

If you don't want IDBroker to generate ids for you then set it
to "none" (or "native" if you want the DBMS to generate them).

You won't be able to use Torque to update your alternate_name
column because by changing it you are altering the only value
available to Torque to use as  a selection criteria for the

What you are attempting to do is widely accepted as bad design
since you cannot change the primary key of your table without
also changing the value that might be stored in any related
tables.  Google "surrogate keys" for the relevant background
information - I know Scott Ambler has written some decent
material about this.

By adding an ALTERNATE_NAME_ID column to your table you should
find everything works out fine.



Scott Eade
Backstage Technologies Pty. Ltd.

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message