连接超类型/子类型? [英] Connecting Supertype / Subtype?

查看:142
本文介绍了连接超类型/子类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须连接Supertype Entity Called




  • 用户(User_ID(PK),User_Password,Registration_Date等)以下实体中的每一个实体都有:





  • 雇员(Employee_ID(PK),Fname,Lname,Birthdate ..等)

  • 客户(Customers_ID(PK),Fname,Lname,Birthdate ..等)

  • 供应商(Supplier_ID(PK),Fname,Lname,Birthdate .. etc)..



如何做(关系数据库)使用Ms-Access?

解决方案

在关系数据库中通常有3种表示继承的策略: p>


  1. 一个表格中的所有内容。

  2. 单独表格中的具体类型。


(3)可能是最常见的,最干净的,即使它可以涉及一点点加盟。在您的情况下,您将在子表中引用FK(引用父级),并通过应用程序逻辑强制执行子级的存在 1 和排他性 2 。可以通过支持循环和延迟FK的DBMS来声明性地执行这些事情,但不能在MS Access中执行。



您可能需要查看这篇文章了解更多信息。






1 所以用户不能只是用户 - 它必须是员工,客户或供应商。



em> 2 所以用户不能(例如)同一个客户和供应商。


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 ?

解决方案

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.

这篇关于连接超类型/子类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆