Thread: Inheritance and Foreign Keys

Inheritance and Foreign Keys

From
Nelio Alves Pereira Filho
Date:
Here's my situation: I have the following relation

table A -----<>------ table B
             1:N

I created the two tables, and a foreign key from A into B. Now I want to
create other tables that inherit from B, but I want that the relation
exists for all of them. For that, I created another table, C, that had
just one field and inherited from B. No errors showed up, but it didn't
complain when I inserted some data into C without the corresponding one
in A!!

Is it possible to do what I intended?

Thanks

--
Nelio Alves Pereira Filho
IFX Networks - www.ifx.com.br
+55 11 3365-5863
nelio@ifx.com.br

Re: Inheritance and Foreign Keys

From
"Oliver Elphick"
Date:
Nelio Alves Pereira Filho wrote:
  >Here's my situation: I have the following relation
  >
  >table A -----<>------ table B
  >             1:N
  >
  >I created the two tables, and a foreign key from A into B. Now I want to
  >create other tables that inherit from B, but I want that the relation
  >exists for all of them. For that, I created another table, C, that had
  >just one field and inherited from B. No errors showed up, but it didn't
  >complain when I inserted some data into C without the corresponding one
  >in A!!
  >
  >Is it possible to do what I intended?

Unfortunately not.  Inheritance is not properly thought out; at present
it allows fields to be duplicated and records selected from an inheritance
hierarchy, but this is relatively useless because constraints are not
inherited and indexes are not shared.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "But because of his great love for us, God, who is rich
      in mercy, made us alive with Christ even when we were
      dead in transgressions-it is by grace you have been
      saved."        Ephesians 2:4,5



Re: Inheritance and Foreign Keys

From
Nelio Alves Pereira Filho
Date:
Is it planned to include these features to class inheritance?

Nelio

Oliver Elphick wrote:
>
> Nelio Alves Pereira Filho wrote:
>   >Here's my situation: I have the following relation
>   >
>   >table A -----<>------ table B
>   >             1:N
>   >
>   >I created the two tables, and a foreign key from A into B. Now I want to
>   >create other tables that inherit from B, but I want that the relation
>   >exists for all of them. For that, I created another table, C, that had
>   >just one field and inherited from B. No errors showed up, but it didn't
>   >complain when I inserted some data into C without the corresponding one
>   >in A!!
>   >
>   >Is it possible to do what I intended?
>
> Unfortunately not.  Inheritance is not properly thought out; at present
> it allows fields to be duplicated and records selected from an inheritance
> hierarchy, but this is relatively useless because constraints are not
> inherited and indexes are not shared.
>
> --
> Oliver Elphick                                Oliver.Elphick@lfix.co.uk
> Isle of Wight                              http://www.lfix.co.uk/oliver
> PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
> GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
>                  ========================================
>      "But because of his great love for us, God, who is rich
>       in mercy, made us alive with Christ even when we were
>       dead in transgressions-it is by grace you have been
>       saved."        Ephesians 2:4,5

--
Nelio Alves Pereira Filho
IFX Networks - www.ifx.com.br
+55 11 3365-5863
nelio@ifx.com.br