Username & Password Database Design

前端 未结 1 1049
青春惊慌失措
青春惊慌失措 2021-01-26 10:58

I\'m Designing a database for industrial company , I Have these entities ( Employee , Suppliers , Customers , Drivers ) and Each one of them has his own unique ID ( Employee Id

相关标签:
1条回答
  • 2021-01-26 11:21

    Create an entity table. Whenever you add an entry to the other tables ( Employee , Suppliers , Customers , Drivers ), add a row in the entity table for them.

    In the other tables ( Employee , Suppliers , Customers , Drivers ), add a foreign key (column name: entity_id).

    To get the entity id for an employee:

    SELECT entity_id FROM employees WHERE id = {employee_id};
    

    As a bonus, fields that are common to all entity types can be moved to the entity table.

    0 讨论(0)
提交回复
热议问题