Common one-to-many table for multiple entities

后端 未结 4 1383
梦谈多话
梦谈多话 2020-12-10 07:13

Suppose I have two tables, Customer and Vendor. I want to have a common address table for customer and vendor addresses. Customers and Vendors can both have one to many ad

4条回答
  •  借酒劲吻你
    2020-12-10 08:15

    How about having four tables with one acting as a gateway to the addresses? So you would have

    Customer
        customerId (PK)
        addressBookId (FK to AddressBook)
    
    Vendor
        vendorId (PK)
        addressBokId (FK to AddressBook)
    
    AddressBook
        addressBookId (PK)
    
    Address
        addressId (PK)
        addressBookId (FK to AddressBook)
    

提交回复
热议问题