问题
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?
回答1:
yes - normalize a little:
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
edited to reflect ypercubes comment with a separate SERVICE table
来源:https://stackoverflow.com/questions/9625213/how-can-i-set-up-a-database-schema-where-there-are-two-concurrent-many-many-rela