数据库设计 - 管理文档 [英] Database design - Managing documents

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

问题描述

我昨天问了一个更普通的问题,并根据这个问题做了一些工作。这个问题更重要的是我想要解决的问题。

I asked a more generic question yesterday and done some work based on this. This question is more to the point in regards to something I am trying to work out.

所以我的应用程序有一个department表来处理部门。所以我可以在我的应用程序,如市场营销和财务不同的部门。

So my application has a departments table to handle departments. So I am able to make different departments within my application such as Marketing and Finance.

问题是,我知道我需要做什么部门,这些将事先创建(但我已经使它像一个CMS,所以管理员可以编辑部门等)。在创建部门后,我想像这样

The problem is, I know what departments I need to make, and these will be created beforehand (but I have made it like a CMS so an admin can edit departments etc). With the departments created, I envision something like this

因此,用户可以从下拉(记住,这是部门创建后)。当他们这样做时,文档下拉列表应该填充。

So a user can choose the department from a dropdown (remember, this is after departments are created). When they do this, the document dropdown should populate.

这是我的问题,如何将特定文档关联到部门?每个文档需要不同的输入,所以我想象他们需要不同的表?目前我有

This is my problem, how can I associate specific documents to a department? Each document requires different inputs, so I would imagine they need to be different tables? At the moment I have

但这并没有真正解决我的问题,我可以说,部门有一个简要文档和概述文档。

But this doesnt really solve my problem whereby I can state that the Marketing department has a Brief document and Overview document.

我怎么可能这样做,因为我没有为每个部门专门设置一个表?

How could I go about doing this seeing that I do not specifically have a table for each department? Would I need to create one for each department?

感谢

推荐答案

您可以执行以下操作:

如果您需要存储的文档信息的种类是大型
,则创建一个包含5列的表:

If the variety of the document's information you need to store is to large create a table which has 5 columns:

id,department_id,crated_at, updated_at, property

所以对于每个属性,您将在表中有一个记录,例如:

so for each property you will have a record in the table e.g:

id   department_id      crated_at        updated_at      property
1         454           2015-08-20       2015-08-22      x:34
2         454           2015-08-26       2015-08-26      z:234
3         934           2015-08-25       2015-08-26      y:45

这样你不需要每个文档都有表类型

This way you won't need table for each document type

EDIT:另一个选项是为属性名称添加一列,并为其值添加一列

another option is adding one column for property name and one for it's value

id,department_id,crated_at, updated_at, property_name, property_value

这篇关于数据库设计 - 管理文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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