这应该很简单.但是我该如何设计呢? [英] This should be simple. But how do I design this?

查看:20
本文介绍了这应该很简单.但是我该如何设计呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种业务单位;部门和部门.一个业务单位必须是其中之一,但不能两者兼而有之.所以这很容易.有一个 BusinessUnit 表和一个包含部门和部门的 BusinessUnitType 查找表.但是,只有部门才能包含团队.每个部门都有一对多的团队.部门没有团队.那我应该在这里做什么?也许我应该在 BusinessUnitType 表上有一个名为 hasTeam 的标志?这是组织这些数据的最佳方式吗?我不确定这个特定的设计是否有名字.

I have 2 kinds of business units; division and department. A business units has to be one or the other, but cannot be both. So this is easy enough. Have a BusinessUnit table and a BusinessUnitType lookup table containing division and department. However only divisions can contain teams. For each division there are one to many teams. Departments do not have teams. So what should I be doing here? Maybe I should have a flag on the BusinessUnitType table called hasTeam? Is that the best way to organise this data? I am not sure if this particular design has a name.

推荐答案

您的案例看起来像是 gen-spec 设计模式的一个实例.Gen-spec 是泛化专业化"的缩写(参见定义).了解继承的程序员熟悉 gen-spec 模式.但是在关系模式中实现 gen-spec 模式可能有点棘手,数据库设计教程通常会跳过这个主题.

Your case looks like an instance of the gen-spec design pattern. Gen-spec is short for "generalization specialization" (see definition ). The gen-spec pattern is familiar to programmers who understand inheritance. But implementing the gen-spec pattern in a relational schema can be a little tricky, and database design tutorials often skip over this topic.

这个话题以前就出现过.(查看示例讨论).

This topic has come up before. (See sample discussion).

幸运的是,网络上有一些很好的文章解释了这个主题(参见示例文章).和谷歌搜索(查看示例搜索) 将产生更多文章.

Fortunately, there are some good articles on the web that explain just this subject (see sample article). And a Google search (see sample search) will yield lots more articles.

这篇关于这应该很简单.但是我该如何设计呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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