Subject Re: [firebird-support] Foreign key different field type
Author livius
>>At DDL time: What happens if you flip the used data types for
ID/ID1?
 
No difference – constraint created
 
regards,
Karol Bieniaszewski
 
Sent: Monday, June 19, 2017 7:21 PM
Subject: Re: [firebird-support] Foreign key different field type
 
 

> Hi,
>
> Can someone show me example when it is usefull to

have different field
> type in relation
>
> Sample
>
Create table test1 (id smallint not null primary key)
>
> Create
table test2 (id1 integer)
>
> Alter table test2 Add foreign key
(id1) references test1(id)
>
> Why this is not
forbidden?

Perhaps cause the referenced column in table test1 can only store a
subset (SMALLINT) of the value range of the INTEGER used in test2?

Even if this works at DDL time, I wonder how strict the optimizer then
is in JOIN statements using an index. Haven't tried.

At DDL time: What happens if you flip the used data types for ID/ID1?

--
With regards,
Thomas Steinmaurer
http://www.upscene.com/

Professional Tools and Services for Firebird
FB TraceManager, IB LogManager, Database Health Check, Tuning etc.

Wolny od wirusów. www.avast.com