本文介绍了如何在有两个并发的多对多关系的情况下建立数据库架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个表来保存停机时间,基本上停机时间事件包含以下信息:
EVENT_ID,START_TIME,END_TIME,服务,原因

主要问题是我不知道如何进行设置,因为我不想最终陷入这样的混乱局面:

I need a table to hold downtime, basically a downtime event contains the following info:
EVENT_ID, START_TIME, END_TIME, SERVICES, CAUSES

The main issue is that I don't know how to set this up because I don't want to end up with a mess like this:

ID  |  EVENT_ID  |  START_TIME  |  END_TIME  | SERVICES  |  CAUSES
01          455       12:00          12:30      FINANCE     NETWORK
02          455       12:00          12:30      ADVANCE     NETWORK
...
13          455       12:00          12:30      REFRESH     DATABASE

基本上...对于一次中断,表中将有许多条目,因为如果有多个服务/原因,则该表实际上将包含所有组合.

Basically...for a single outage, I would have many many entries in the table, since if there are multiple services/causes, the table would in effect hold all combinations.

是否有一种更有效的组织方式?

Is there a more efficient way of organizing this?

推荐答案

是-稍微标准化一下:

EVENT
------
event_id
start_tm
end_tm
description

EVENT_SERVICE
-------------
event_id
service_id
employee_id 
start_tm
end_tm
(other info as needed)

SERVICE
---------
service_id
description

CAUSE
-------
cause_id
description

EVENT_CAUSE
-----------
event_id
cause_id

编辑,以使用单独的SERVICE表反映超级立方体的评论

edited to reflect ypercubes comment with a separate SERVICE table

这篇关于如何在有两个并发的多对多关系的情况下建立数据库架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 12:50