Constraints with several father tables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralf

    Constraints with several father tables

    Hi,

    I have 4 tables: "T_father1",... ,"T_father4" .
    In relation to these father-tables I have a child-table: "T_Child"
    (with only 1 foreignkey-field: FsID) alread filled with some records.

    That means each record of "T_Child" has in its field "FsID" a primary
    key of one of the 4 father tables.

    If I want to create the 4 foreign-key CONSTRAINTS:
    "T_Child.Fs ID <-T_FatherX.ID" (X=1..4)
    I get an Oracle-error (Ora-02298): "cannot validate".

    My question is:
    How can I tell Oracle (how do I have to create the Constraint), that
    this foreignkey-field "T_Child.Fs ID" is not the foreign-key to ONE
    father-table but to FOUR father tables ?
    Or is this "bad database design" to have one foreignkey-field for 4
    father tables ?

    Thanks in advance for any help, suggestionst or comments !!
    Best regards
    Ralf Miko
  • Sybrand Bakker

    #2
    Re: Constraints with several father tables

    Miko@boehrer.de (Ralf) wrote in message news:<fa624200. 0307240031.2027 8673@posting.go ogle.com>...
    Hi,
    >
    I have 4 tables: "T_father1",... ,"T_father4" .
    In relation to these father-tables I have a child-table: "T_Child"
    (with only 1 foreignkey-field: FsID) alread filled with some records.
    >
    That means each record of "T_Child" has in its field "FsID" a primary
    key of one of the 4 father tables.
    >
    If I want to create the 4 foreign-key CONSTRAINTS:
    "T_Child.Fs ID <-T_FatherX.ID" (X=1..4)
    I get an Oracle-error (Ora-02298): "cannot validate".
    >
    My question is:
    How can I tell Oracle (how do I have to create the Constraint), that
    this foreignkey-field "T_Child.Fs ID" is not the foreign-key to ONE
    father-table but to FOUR father tables ?
    Or is this "bad database design" to have one foreignkey-field for 4
    father tables ?
    >
    Thanks in advance for any help, suggestionst or comments !!
    Best regards
    Ralf Miko

    I wouldn't even call this design. Multiple foreign keys in multiple
    tables to 1 PK are definitely possible. One foreign key to multiple
    parents of course not.
    Your parent table must be falling apart in several subtypes. Hence you
    need to differentiate.

    Sybrand Bakker
    Senior Oracle DBA

    Comment

    Working...