Avoid Circular Dependency

前端 未结 2 1506
野的像风
野的像风 2021-02-09 17:35

I am developing a travel management application. The design in question is something like following :

Each person in a tour is designated as a Traveler. Each Traveler ha

2条回答
  •  攒了一身酷
    2021-02-09 18:27

    I would only have two tables in the database.

    Traveller and Password

    Traveller will have a Parent_Id field which will link back to the Traveller table and will store who the Main/Head traveller is. Also store fields common to either Main/Sub member in this table like contact number

    Then using inheritance and ORM create two different classes in your actual application. MainMember and SubMember MainMember would be all rows in Traveller where Parent_Id is null SubMember would be all rows in Traveller where Parent_Id is not null

提交回复
热议问题