数据库设计:OR 关系 [英] Database design: OR relation
问题描述
我有一个带有用户"表的数据库,其中包含有关我的用户的数据.每个用户都将链接到一家公司或一所大学.我希望有两个单独的表学院"和公司",每个表都有一个字段ID".那么如何将用户表中的每条记录链接到公司或大学?
I have a database with a "users" table containing data about my users. Each user is to be linked to a company or a college. I wish to have two separate tables "college" and "company" each with a field "ID". So how do I link each record in the users table to either a company or a college?
基本的事情是我想在数据库中建立一个或"关系.
The basic thing is that I wish to establish an "OR" relationship in the database.
推荐答案
您可以使用子类型/超类型关系.保留组织表中的所有常见字段.College 和 company 表仅包含特定于这些实体的字段.
You can use subtype/super-type relationship. Keep all common fields in the organization table. College and company tables contain only fields specific to those entities.
这篇关于数据库设计:OR 关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!