我们正在构建一个基于微服务的物联网平台,该平台具有仪表板和各种传感器的视图等。我看过一些数据建模视频,但无法在cassandra中获得良好的数据模型。我需要同样的帮助。
因此,用例如下:
我们正在为每个组织的每个用户提供个性化的仪表板。例如,考虑为仓库监控解决方案构建物联网平台。仓库可以拥有一堆设备,每个设备都由一堆设备监控。因此,我的层次结构如下所示:
组织>>有许多仓库>>有许多设备>>有许多设备。一个组织有几个用户/员工,每个用户/员工的级别不同,例如仓库经理,首席执行官,区域经理等
因此,仪表板具有大量必须根据登录用户显示的统计信息。这些统计数据是
1)用户可以看到的仓库总数(例如,首席执行官为500000,区域经理为50)
2)这些仓库中可用的设备总数(例如,首席执行官为10000000,区域经理为300)
3)10000000设备的设备状态计数(例如,CEO的POWERED_ON(50000),POWERED_OFF(50000),MAINTAINENECE(50000),DISMANTLED(50000)等)以及POWERED_ON(100),POWERED_OFF(100) ,MAINTAINENECE(50),DISMANTLED(50))
4)为设备和装置生成的警报总数。 (假设15000台设备处于“关键”状态,必须立即为CEO修复,而15台设备处于“关键”状态以供区域经理使用)
对于仓库特定的数据,我提出的模型如下:
//Org >> to user >> to warehouse >> to equipment mapping
@PartitionKey(0)
private String organization;
@PartitionKey(1)
private String userId;
@ClusteringColumn(0)
private UUID warehouseUuid;
@ClusteringColumn(1)
private UUID equipmentUuid;
@ClusteringColumn(2)
private LocalDateTime timeOfEquipmentStatusUpdate;
private EquipmentState currentEquipmentState;
//Equipment state Audit information
@PartitionKey(0)
private UUID warehouseUuid;
@PartitionKey(1)
private UUID equipmentUuid;
@ClusteringColumn(0)
private LocalDateTime timeOfEquipmentStatusUpdate;
private EquipmentState currentEquipmentState;
随着技术人员对其进行修复,设备状态将不断更新。这将在后台作业的第一个表上运行更新查询,以更新设备状态信息。
由于仪表板只处理计数,我在想一个查询可以为用户获取一行数据,然后计算应用程序中仓库和设备的数量。
但是,我在警报方面做得更多,因为当警报发出时,所有可以查看站点/设备的用户都应该看到警报。我不认为我可以将AlertType(CRITICAL / INFO / WARNING)作为分区键。
sql查询可能类似于
select count(alertType) from <table> where userid = 'userId' and orgId ='orgId' and warehouse in ('1','2','3' ...n) group by alertType;
我想出的一种警报模型是
//Alert audit information
@PartitionKey(0)
private UUID warehouseUuid;
@PartitionKey(1)
private String equipmentUuid;
@ClusteringColumn(0)
private LocalDateTime eventOccurrenceTime;
@ClusteringColumn(1)
private String alertName;
private AlertType alertType;
我不确定如何将组织中的用户映射到此警报信息。有人可以帮我进行数据建模吗?
谢谢。