What's the difference between identifying and non-identifying relationships?

前端 未结 15 1663
迷失自我
迷失自我 2020-11-22 12:02

I haven\'t been able to fully grasp the differences. Can you describe both concepts and use real world examples?

15条回答
  •  死守一世寂寞
    2020-11-22 12:17

    Non-identifying relationship

    A non-identifying relationship means that a child is related to parent but it can be identified by its own.

    PERSON    ACCOUNT
    ======    =======
    pk(id)    pk(id)
    name      fk(person_id)
              balance
    

    The relationship between ACCOUNT and PERSON is non-identifying.

    Identifying relationship

    An identifying relationship means that the parent is needed to give identity to child. The child solely exists because of parent.

    This means that foreign key is a primary key too.

    ITEM      LANGUAGE    ITEM_LANG
    ====      ========    =========
    pk(id)    pk(id)      pk(fk(item_id))
    name      name        pk(fk(lang_id))
                          name
    

    The relationship between ITEM_LANG and ITEM is identifying. And between ITEM_LANG and LANGUAGE too.

提交回复
热议问题