You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Weaver, Scott" <Sw...@rippe.com> on 2001/11/09 16:55:38 UTC
Multiple Primarary Keys and using Turbine Auto-increment
Quick question before I end up digging a hole for myself that will suck to
climb out of.
Is it okay for me to have table that has a two field primary key were one
field is auto-increment and the other is not. This would be for a simple
parent to children relationship where each child's primary key consists of
the parent's primary key and the child's auto-generated key.
schema example:
<!--
- Generic product characteristics type table. Example: Color, Size, Length
-->
<table name="CHARACTERISTIC_TYPE" idMethod="idbroker">
<column name="CHARACTERISTIC_TYPE_ID" autoIncrement="true"
primaryKey="true" required="true" type="INTEGER"/>
<column name="CHARACTERISTIC_TYPE_NAME" required="true"
type="VARCHAR" size="75"/>
<column name="CHARACTERISTIC_TYPE_TEXT" required="false"
type="LONGVARCHAR" />
<unique>
<unique-column name="CHARACTERISTIC_NAME"/>
</unique>
</table>
<!--
- Specific Characteristics
-->
<table name="CHARACTERISTIC" idMethod="idbroker">
<column name="CHARACTERISTIC_TYPE_ID" primaryKey="true"
required="true" type="INTEGER"/>
<column name="CHARACTERISTIC_ID" autoIncrement="true"
primaryKey="true" required="true" type="INTEGER"/>
<column name="CHARACTERISTIC_NAME" required="true" type="VARCHAR"
size="75"/>
<column name="CHARACTERISTIC_TEXT" required="false"
type="LONGVARCHAR" />
<foreign-key foreignTable="CHARACTERISTIC_TYPE">
<reference local="CHARACTERISTIC_TYPE_ID"
foreign="CHARACTERISTIC_TYPE_ID"/>
</foreign-key>
</table>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Multiple Primarary Keys and using Turbine Auto-increment
Posted by Jason van Zyl <jv...@zenplex.com>.
On 11/9/01 10:55 AM, "Weaver, Scott" <Sw...@rippe.com> wrote:
> Quick question before I end up digging a hole for myself that will suck to
> climb out of.
>
> Is it okay for me to have table that has a two field primary key were one
> field is auto-increment and the other is not. This would be for a simple
> parent to children relationship where each child's primary key consists of
> the parent's primary key and the child's auto-generated key.
Sorry, but I completely fail to understand why anyone would use anything
other than a single integer for the primary key. Your unique identifier
shouldn't have any business meaning or your just asking for trouble.
Take a peek at section 2.1 in
http://www.ambysoft.com/mappingObjects.pdf
> schema example:
>
> <!--
> - Generic product characteristics type table. Example: Color, Size, Length
> -->
> <table name="CHARACTERISTIC_TYPE" idMethod="idbroker">
> <column name="CHARACTERISTIC_TYPE_ID" autoIncrement="true"
> primaryKey="true" required="true" type="INTEGER"/>
> <column name="CHARACTERISTIC_TYPE_NAME" required="true"
> type="VARCHAR" size="75"/>
> <column name="CHARACTERISTIC_TYPE_TEXT" required="false"
> type="LONGVARCHAR" />
> <unique>
> <unique-column name="CHARACTERISTIC_NAME"/>
> </unique>
> </table>
>
> <!--
> - Specific Characteristics
> -->
>
> <table name="CHARACTERISTIC" idMethod="idbroker">
> <column name="CHARACTERISTIC_TYPE_ID" primaryKey="true"
> required="true" type="INTEGER"/>
> <column name="CHARACTERISTIC_ID" autoIncrement="true"
> primaryKey="true" required="true" type="INTEGER"/>
> <column name="CHARACTERISTIC_NAME" required="true" type="VARCHAR"
> size="75"/>
> <column name="CHARACTERISTIC_TEXT" required="false"
> type="LONGVARCHAR" />
>
> <foreign-key foreignTable="CHARACTERISTIC_TYPE">
> <reference local="CHARACTERISTIC_TYPE_ID"
> foreign="CHARACTERISTIC_TYPE_ID"/>
> </foreign-key>
> </table>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
jvz.
Jason van Zyl
http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>