Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012

    Relational DB modelling strange relationships with(out) foreign key constraint

    Hello all,

    I have a class of tables which I need to relate to a single table. Ideally, I would like to make use of DB foreign key constrains (as the rest of the app has done), however there are some issues with respect to the relationship that makes this a bit difficult. I'll discuss the details below.

    Let's say I have a class of similar tables (A1, A2, A3). Logically, these are the parent tables which have related children in table B. I'm struggling with how to implement a foreign key on table B that is constrained to the primary key of table A1 OR table A2 OR table A3.

    The only options I see are to forgo FK constraints at the DB layer, or duplicate an identical table B for each of the A tables (A1->B1, A2->B2, A3->B3).

    Any insight or advice would be greatly appreciated.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    advice would be a lot easier to come up with if we were talking about actual tables instead of As and Bs

    a foreign key relationship can reference only one table

    so if a table has to reference three different tables, it'll need three different foreign keys | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts