问题描述
我有一个接收警报(交通,抢劫等)的系统,其中几个警报属于同一事件(从不同来源得知),但是该事件是相同的,因此我应该能够将它们分组,就像twitter只是显示一个可以看到其他选项的选项(在twitter:请参见对话),我的疑问是这种关系的设计,其中id_alert_f是父亲(第一个),其他分组在其下,那些id_alert_c(孩子)
I have a system that receive alerts(traffic, robbery,...), of which several belong to the same event(that is told from different sources), but the event is the same, so i should be able to group them and like twitter just show one with the option to see the others(in twitter:see conversation), my doubt is with the design of this relation, with id_alert_f being the father(the first) and the others grouped under it, those id_alert_c (child)
表警报
id_alert, message, date, id_category, id_location
表事件
id_event, id_alert_f
表events_alert
table events_alert
id_alert_f, id_alert_c
该设计是否能够正确地支持该目的?
is this design going to be able to support correctly that end?
推荐答案
我认为您不需要events_alert表,仅当警报和事件是n:n关系时才需要.
I don't think you need the events_alert table, this would only be needed if alert and event is a n:n relation.
事件
------
id_event
event
------
id_event
警报
------
id_alert
id_event
消息
日期
id_category
id_location
alert
------
id_alert
id_event
message
date
id_category
id_location
id_alert_f可以添加到事件中,也可以按最小日期前的顺序检索(以获取第一个),或以is_father的形式在警报中使用布尔值
id_alert_f could be added to event, could also be retreived with a order by min date [to get the first], or a boolean in the alert as is_father
这篇关于用于分组的数据库设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!