Connecting Supertype / Subtype?

泪湿孤枕 提交于 2019-12-25 04:15:51

问题


I have to connect Supertype Entity Called

  • Users ( User_ID (PK) , User_Password , Registration_Date , .. etc ) .

to Each one of the following entities :

  • Employees ( Employee_ID (PK) , Fname , Lname , Birthdate .. etc )
  • Customers ( Customers_ID (PK) , Fname , Lname , Birthdate .. etc )
  • Suppliers( Supplier_ID (PK) , Fname , Lname , Birthdate .. etc ) ..

How To Do It ( For relational database ) Using Ms-Access ?


回答1:


There are generally 3 strategies for representing inheritance in the relational databases:

  1. Everything in one table.
  2. Concrete types in separate tables.
  3. All types in separate tables.

The (3) is probably most common and most "clean" even though it can involve a fair bit of JOINing. In your case, you'd have FKs in child tables (referencing the parent) and enforce the presence1 and exclusivity2 of the child through the application logic. It is possible to enforce these things declaratively through the DBMS supporting circular and deferred FKs, but not in MS Access.

You might want to take a look at this post for more info.


1 So user cannot be just user - it must be either employee, customer or supplier.

2 So user cannot be (for example) a customer and a supplier at the same time.



来源:https://stackoverflow.com/questions/12050849/connecting-supertype-subtype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!