db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Libor Jelinek <ljeli...@virtage.com>
Subject Re: How to drop two interrelated tables at the same time?
Date Fri, 10 Feb 2012 12:49:16 GMT
Right, John. Because these two tables reference each other with FK
constraints thus one column must allow null. Then it's application logic's
responsibility to ensure that immediately when referenced row from second
table is created it is set in first table (i.e. not leaving it null).

By the way are there some methodologies in response to this "Columbus's
egg" problem?

Thank you for your helpful responses!
Libor

2012/2/10 John English <john.foreign@gmail.com>

> On 10/02/2012 02:22, Bergquist, Brett wrote:
>
>> Use
>>
>> alter table business_objects drop constraint fk_created_by;;
>> alter table users drop constraint fk_boid;
>> drop table business objects;
>> drop table users;
>>
>> Basically reverse what you did to create the tables.
>>
>> Brett
>>
>
> As a matter of interest, how would you ever insert data into these two
> tables? Inserting into either one would violate the FK constraint in
> the other, unless the FK allowed nulls -- in which case you do an insert
> with a null key into one table, an insert with non-null into the other,
> and then an update of the first table's FK. Or am I missing something?
>
> ------------------------------**------------------------------**
> ------------
>  John English | My old University of Brighton home page is still here:
>              | http://www.cem.brighton.ac.uk/**staff/je/<http://www.cem.brighton.ac.uk/staff/je/>
> ------------------------------**------------------------------**
> ------------
>

Mime
View raw message