子类型数据库表 [英] Subtyping database tables

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

问题描述

在设计数据库时,我听到很多关于子表的表,我完全了解了它们背后的理论。但是,我从来没有看到表格子类型在行动。你如何创建表的子类型?我正在使用MS Access,我正在寻找一种在SQL中以及通过GUI(Access 2003)执行此操作的方法。

I hear a lot about subtyping tables when designing a database, and I'm fully aware of the theory behind them. However, I have never actually seen table subtyping in action. How can you create subtypes of tables? I am using MS Access, and I'm looking for a way of doing it in SQL as well as through the GUI (Access 2003).

干杯!

推荐答案

一个简单的例子就是让一个Person表中的主键和该表中的一些列。现在,您可以创建另一个名为Student的表,该表具有person表(其超类型)的外键。现在学生表中有一些列,超类型不像GPA,Major等,但名称,姓氏等将在父表中。您可以随时通过学生表中的外键在Person表中访问学生姓名。

An easy example would be to have a Person table with a primary key and some columns in that table. Now you can create another table called Student that has a foreign key to the person table (its supertype). Now the student table has some columns which the supertype doesn't have like GPA, Major, etc. But the name, last name and such would be in the parent table. You can always access the student name back in the Person table through the foreign key in the Student table.

无论如何,只要记住以下内容:

Anyways, just remember the following:


  • 层次结构描述了超类型和子类型之间的关系

  • 超类型具有共同属性

  • 子类型有uniques属性

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

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