You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Tatu Vanhanen <ta...@regex.fi> on 2002/01/04 10:14:50 UTC
Torque, handling of table references
I have been trying to figure out how Torque (3.0 dev) handles object
(=table) references.
The situation I have in mind is when you delete a record from database
through the BaseXXXPeer.doDelete- method. What happens to the related
records? Do I have to first delete all related records and then the "main"
record.
For example, if I delete a course, do I have to delete all bookings to that
course "by hand", or does Torque handle this? As I understands so far, I
have to delete related records by hand.
The table structure and XML schema are as follows (simplified):
Table structure:
CREATE TABLE course
(
id INTEGER NOT NULL,
short_name VARCHAR (40),
description MEDIUMTEXT,
duration INTEGER,
PRIMARY KEY(id)
);
CREATE TABLE booking
(
id INTEGER NOT NULL,
course_id INTEGER,
trainees INTEGER,
information MEDIUMTEXT,
PRIMARY KEY(id),
FOREIGN KEY (course_id) REFERENCES course (id)
);
XML schema:
<table idMethod="idbroker" name="course">
<column name="id" required="true" primaryKey="true" type="INTEGER"/>
<column name="short_name" size="40" type="VARCHAR"/>
<column name="description" type="LONGVARCHAR"/>
<column name="duration" type="INTEGER"/>
</table >
<table idMethod="idbroker" name="booking">
<column name="id" required="true" primaryKey="true" type="INTEGER"/>
<column name="course_id" type="INTEGER"/>
<column name="trainees" type="INTEGER"/>
<column name="information" type="LONGVARCHAR"/>
<foreign-key foreignTable="course">
<reference local="course_id" foreign="id"/>
</foreign-key>
</table >
Thanks!
- Tatu v.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>