Subject Re: [firebird-support] Foreign key different field type
Author Ann Harrison
On Mon, Jun 19, 2017 at 1:21 PM, Thomas Steinmaurer ts@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
,
>
> Can someone show me example when it is usefull to have different field
> type in [referenced and referencing keys of a foreign key relationship]?
>
>
> Why this is not forbidden?

Why should it be forbidden?  Not everything that's dumb is disallowed. 

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.

Nor have I tried, but Firebird uses the same key representation for most numeric
columns, so having mixed sizes of numbers - or different scales -  in a foreign key
shouldn't matter to the optimizer.  The exception - which may have been changed - 
was the representation of int64. Having a single key format for numbers makes 
it simple to increase the size of columns or change the scale.

Good luck,

Ann