Subject Re: [firebird-support] Help with a query
Author Fulvio Senore
Il 20/12/2013 16:32, Mark Rotteveel ha scritto:
> On Fri, 20 Dec 2013 14:15:38 +0100, Fulvio Senore <mailing@...>
> wrote:
>> I have two tables, for example TableA and TableB.
>>
>> Each row of TableA contains a foreign key to a row of TableB.
>> This a 1 to 1 relation, so each row of TableA is linked to one different
>
>> row of TableB.
>> The foreign key field can also be NULL, in this case the TableA row is
>> not connected to a TableB row.
>>
>> All TableB rows depend logically on TableA rows, so all TableB rows
>> should be linked by a TableA row.
>>
>> I would like to check for program errors during development, so I would
>> like to know if there are "orphans" TableB rows.
>>
>> May somebody suggest me a good way to find the rows in TableB that are
>> not connected from any row in TableA?
>
> To me it sounds like you have the dependencies reversed: TableB should
> have a foreign key to TableA, and not the other way around.
>

Many thanks to everybody who helped with my question.

I was also wondering if I can find a better design, but it's good to
know how to solve my problem.

Fulvio Senore