Association between two entries in SQL table

后端 未结 3 1624
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 03:26

Imagine you have a database table that stores a list of people. You want to establish a relationship between peoples, i.e., person I is friend with person J.

I suppo

3条回答
  •  青春惊慌失措
    2021-01-01 04:02

    You might also want to establish the type of reletionship. In this case you'd ideally use 2 tables, RelationshipTypes and Relationships. The unique key could be on all 3 Relationship fields.

    Relationships
      PersonId
      RelatedPersonId
      RelationshipTypeId
    
    RelationsShipTypes
      Id
      Name
    

提交回复
热议问题