Many to Many Relation Design - Intersection Table Design

后端 未结 11 1479
野的像风
野的像风 2020-12-07 19:20

I\'m wondering what a better design is for the intersection table for a many-to-many relationship.

The two approaches I am considering are:

CREATE TA         


        
11条回答
  •  天涯浪人
    2020-12-07 19:52

    Given that the TableAId-TableBId combination is unique and that the table is used solely to implemet a many-to-many relationship I would go with the second option. From a purely logical standpoint the fist implemtnation reduces to the second. From a structural perspective your databases needs to maintain both a primary key/index as well as a constraint on the first implementation wereas on the second it only needs to maitain the primary key/index.

提交回复
热议问题