现在,我有一个二维网格,它显示了特定(2)服务的(1)需求。它在前端看起来像这样:
FEATURE TRAILER MARKETING
DVD x
Streaming x x
Theatrical x x我现在在数据库中存储它的方式是:
`service`
- id
- name (e.g., "DVD")
` requirements`
- id
- name (e.g., "Marketing")
`requirements_grid`
- service_id
- requirement_ids (csv of all requirement ids)现在,我可以这样说:“对于DVD,我需要一个特性作为需求。”
我现在需要添加两个额外的参数,(3)内容类型;(4)提供者。这些将是来自默认需求网格的更改(添加或删除)。
这将允许我描述类似“对于Fox (提供商)的电视(内容类型) DVD,我需要一个功能和一个预告片。
我该如何构造数据库来存储它呢?另外,有什么可能的方式将其显示在前端?
发布于 2013-06-20 03:01:43
要回答您的第一个问题--如何存储一个四维网格--只需按照您已经准备好的方向继续,但要规范化requirement_ids列。
所以在当前的模式中,如果您有
| service_id | requirement_ids |
| 1 | 1,2,3 |
| 2 | 2 |在新的模式中,您将获得:
| service_id | requirement_id |
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 2 | 2 |在此更改之后,添加新维度非常容易:
`service`
- id
- name (e.g., "DVD")
` requirements`
- id
- name (e.g., "Marketing")
`content_type`
- id
- name
`provider`
- id
- name
`requirements_grid`
- service_id
- requirement_id
- content_type_id
- provider_id我不能帮你回答另一个问题。考虑把它移到一个单独的Stackoverflow问题上。
发布于 2013-06-20 03:47:19
CREATE TABLE requirement
(service_id INT NOT NULL
requirement_id INT NOT NULL
content_type --type??
provider --type??,
PRIMARY KEY ? (service_id,requirement_id,content_type,provider type));发布于 2013-06-21 08:13:01
这是我根据反馈选择的模式:
`requirements_grid`
- service_id NOT NULL
- requirement_ids (csv of all requirement ids) NOT NULL
- content_type
- provider保留csv字段只是让我更容易访问它。
https://stackoverflow.com/questions/17198674
复制相似问题