Results 1 to 5 of 5

Thread: Erwin Fk

  1. #1
    Join Date
    Feb 2009

    Erwin Fk

    Hello all,

    I have such question.
    When I create relations in ERWIN it sets foreign keys (FK), Witch are primary keys from the related table. I understand this. But, it also sets FK from primary keys of the table is related to table related to this table.

    for example:

    table 1 -> table 2
    pk - tbl1_id
    table 2 -> table 3
    pk - tbl2_id
    fk - tbl1_id
    table 3
    pk - tbl3_id
    fk - tbl2_id
    fk - tbl1_id

    ERWIN does it automatically when I set identifying relationships.
    Why doest it do so? And what is sense of setting this cross table FKs
    Is it good for db??
    If it is bad how to disable it in ERWIN. To set foreign keys only to directly related tables. Or it is better to set fk for all tables that have relation to current table?

  2. #2
    Join Date
    Dec 2007
    London, UK
    Could it be that you've unintentionally made a compound key out of the two columns in Table 2? That would explain why the two columns are then used for the foreign key in Table 3.

    It might be clearer if you post the actual SQL for these tables rather than pseudo-code.

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    ErWin is doing the right thing.

    If the relationship between table1 and table2 is identifying, then a row in table2 can't exist without a corresponding row in table1 This in turn implies that the PK from table1 is actually a part of the PK of table2.

    Since the PK of table2 is actually the combination of tbl1_id and tbl2_id, those two columns need to be carried forward into table3 as FK attributes.

    ErWin is software, and like any software it could have bugs. You are wise to challenge what ErWin does automatically, but ErWin is one of the very few software packages that I will assume it is correct until I can positively prove that it is in error and that happens very, very rarely!


  4. #4
    Join Date
    Apr 2002
    Toronto, Canada
    Quote Originally Posted by dportas
    Could it be that you've unintentionally made a compound key out of the two columns in Table 2?
    erwin makes a distinction between identifying realtionships and non-identifying relationships (there are two different buttons on the toolbar)

    identifying relationships by definition propagate the keys

    so it couldn't have been unintentional -- perhaps just unknowing | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2009
    Thnks Pat Phelan and all who answered. Now I get it!

Posting Permissions

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