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

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

问题描述

我有2种业务单位;部门和部门。业务单位必须是一个或另一个,但不能同时存在。
所以这很简单。拥有一个BusinessUnit表和一个包含部门和部门的BusinessUnitType查找表。
但是只有部门可以包含团队。对于每个部门,有一对多的团队。部门没有团队。
那么我应该在这里做什么?也许我应该在名为hasTeam的BusinessUnitType表上有一个标志?
这是组织这些数据的最好方法吗?
我不知道这个特定的设计是否有一个名字。

解决方案

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



此主题已经出现。 (参见样本讨论)。



幸运的是,网页上有一些很好的文章仅仅解释了这个问题(参见示例文章)。和Google搜索(查看样本搜索)将会收到更多文章。


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.

解决方案

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天全站免登陆