db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Palomares <rpmdisguise-j...@yahoo.es>
Subject Any workaround for unique constraints?
Date Mon, 05 May 2008 22:28:13 GMT
Hi,

Some time ago (about a year) I asked about a problem with unique
constraints, and I was told that DdlUtils didn't support it and that
it was intended to work for DdlUtils 1.1. Now I've seen that it is
targeted for 1.2:

http://issues.apache.org/jira/browse/DDLUTILS-85

which is perfectly normal and I bear with it (especially since I've
progressed with my app much less than DdlUtils in this whole year).
:-) However, I'd really like to be able to use DdlUtils so when I ship
the application, my users don't have to mess themselves with SQL
commands in case I change the DB schema (and I will likely change over
time).

The typical case I'm hitting is:

Table1:
 - ID: synthetic PK
 - T1CODE: "user-friendly" code, guaranteed to be unique

Table2:
 - ID: synthetic PK
 - T1CODE: foreign key to Table1.T1CODE
 - T2CODE: "user-friendly" code, unique when concatenated to T1CODE.

The reason why I don't want to base Table2 foreign key on Table1.ID is
to avoid double queries just to retrieve T1CODE.

The reason why I don't want to set T1CODE the PK is because there are
(minimal) chances for T1CODE values to change over time. Although they
should always be unique, I'd rather not depend on this being true.

So, assuming I can't declare unique constraints and that sometimes I
won't be able to base foreign keys dependencies on primary keys, is
there any way I can still use DdlUtils while declaring those kind of
foreign keys?

TIA

-- 
Command line: The most efficient method available for accidentally
deleting data. (The Devil's Dictionary)
* TagZilla 0.066 *


Mime
View raw message