跳到主要内容

MyEMS 数据库设计:13 个业务库

目录​

数据库架构设计​

MyEMS 使用 13 个 MySQL 数据库。安装脚本位于 database/install。每个脚本创建一个数据库,字符集为 utf8mb4,排序规则为 utf8mb4_unicode_ci。表使用 BIGINT 主键、UTC 的 DATETIME 列,测量值和汇总值使用 DECIMAL(21, 6)。

数据库表数量用途
myems_system_db166主数据:空间、计量表、数据点、设备、电站、费率和关联关系
myems_historical_db12数据点原始值和上传的费用、离线表、修复、计划文件
myems_energy_db39小时能耗汇总
myems_billing_db39小时费用汇总,表集合与能耗库相同
myems_carbon_db39小时碳排放汇总,表集合与能耗库相同
myems_energy_baseline_db39小时基准,表集合与能耗库相同
myems_energy_model_db398760 小时典型年,对象集合与能耗库相同
myems_energy_plan_db39小时计划,表集合与能耗库相同
myems_energy_prediction_db39小时预测,表集合与能耗库相同
myems_fdd_db9故障规则,以及邮件、短信、网页和微信消息
myems_user_db10用户、权限、会话、API 密钥和审计日志
myems_reporting_db4报表定义、模板、生成文件和报表邮件
myems_production_db8产品、班组、班次和小时产量

设计理念​

数据库职责写入方
myems_system_db配置和拓扑Web 界面经 myems-api
myems_historical_db数据点时间序列和上传的工作簿数据采集和文件导入
myems_energy_db小时能耗规范化和汇总
myems_billing_db小时费用计费,依据能耗值和费率
myems_carbon_db小时排放碳排放计算,依据能耗值和排放因子
myems_energy_baseline_db小时基准基准服务
myems_energy_model_db非闰年每个小时一个值建模服务
myems_energy_plan_db小时计划计划服务
myems_energy_prediction_db小时预测预测服务
myems_fdd_db规则和出站通知FDD 服务
myems_user_db身份和权限API
myems_reporting_db定时报表报表服务
myems_production_db用于能耗强度的产量产量导入和汇总

配置对象之间用 id 互相引用。跨库表保存同一个 id,不声明指向另一个数据库的外键。

命名规范​

对象规则示例
数据库myems_ 前缀,_db 后缀myems_system_db
表tbl_ 前缀tbl_meters
关联表tbl_{owner}_{child}tbl_spaces_meters
小时事实表{object}_{measure}_hourlytbl_meter_hourly
模型事实表同一对象集合,_8760 后缀tbl_meter_8760
主键idid BIGINT NOT NULL AUTO_INCREMENT
业务键配置对象上的 uuid CHAR(36)计量表、空间、设备
时间*_datetime_utc 或 utc_date_timestart_datetime_utc
索引{table}_index_{n}tbl_meters_index_1

数据库详细说明​

1. 系统数据库 (myems_system_db)​

myems_system_db 保存主数据,共 166 张表。配置对象通常包含 id、name、uuid 和 description。关联表只保存两个外键(以及 id)。电站下的部件表为每台物理设备存一行,并配有对应的 *_points 表。

能源分类​

表关键字段说明
tbl_energy_categoriesname, uuid, unit_of_measure, kgce, kgco2e能源分类及默认换算系数
tbl_energy_itemsname, uuid, energy_category_id分类下的分项

kgce 和 kgco2e 是分类上的默认系数。有时间范围的价格和排放因子存放在费率和排放因子表中。

计量表和数据点​

表关键字段说明
tbl_metersenergy_category_id, energy_item_id, cost_center_id, master_meter_id, is_counted, is_enabled, hourly_low_limit, hourly_high_limit在线计量表
tbl_offline_meters相同的限值和分类字段,没有 master_meter_id手工录入的计量表
tbl_virtual_metersequation (LONGTEXT), energy_category_id, energy_item_id, is_counted, is_enabled由公式计算的计量表
tbl_variablesname, virtual_meter_id, meter_type, meter_id虚拟表公式中的变量绑定
tbl_pointsdata_source_id, object_type, units, high_limit, low_limit, higher_limit, lower_limit, ratio, offset_constant, is_trend, is_virtual, address, faults, definitions数据点。address、faults 和 definitions 为 JSON 文本。数据点没有 uuid
tbl_points_set_valuespoint_id, utc_date_time, set_value, is_set数据点的设定值
tbl_meters_pointsmeter_id, point_id计量表与数据点的绑定
tbl_meters_commandsmeter_id, command_id计量表与命令的绑定

tbl_points 上的 higher_limit、lower_limit 和 is_in_alarm 供 FDD 服务使用。ratio 和 offset_constant 用于缩放原始值。

数据采集​

表关键字段说明
tbl_gatewaysname, uuid, token, last_seen_datetime_utc采集网关
tbl_data_sourcesgateway_id, protocol, connection (LONGTEXT), process_id, last_seen_datetime_utc网关下的连接。connection 为 JSON
tbl_protocolsname, code协议目录
tbl_sensorsname, uuid传感器
tbl_sensors_pointssensor_id, point_id传感器与数据点的绑定
tbl_iot_sim_cardsiccid, imsi, operator, status, used_traffic, total_trafficSIM 卡台账。此表没有 uuid

空间和成本中心​

表关键字段说明
tbl_spacesparent_space_id, area, number_of_occupants, timezone_id, contact_id, cost_center_id, latitude, longitude, is_input_counted, is_output_counted空间树
tbl_cost_centersname, uuid, external_id成本中心
tbl_contactsname, uuid, email, phone联系人
tbl_timezonesname, utc_offset时区
tbl_working_calendarsname工作日历
tbl_working_calendars_non_working_daysworking_calendar_id, date_local, description非工作日

空间通过关联表连接下级对象,这些对象上没有 space_id 列:

tbl_spaces_meters, tbl_spaces_offline_meters, tbl_spaces_virtual_meters, tbl_spaces_points, tbl_spaces_sensors, tbl_spaces_equipments, tbl_spaces_combined_equipments, tbl_spaces_commands, tbl_spaces_shopfloors, tbl_spaces_stores, tbl_spaces_tenants, tbl_spaces_charging_stations, tbl_spaces_microgrids, tbl_spaces_photovoltaic_power_stations, tbl_spaces_energy_storage_power_stations, tbl_spaces_wind_farms, tbl_spaces_distribution_systems, tbl_spaces_energy_flow_diagrams, tbl_spaces_working_calendars.

设备​

表关键字段说明
tbl_equipmentsis_input_counted, is_output_counted, is_enabled, cost_center_id, efficiency_indicator, svg_id, camera_url设备
tbl_combined_equipments与 tbl_equipments 相同的字段组合设备
tbl_combined_equipments_equipmentscombined_equipment_id, equipment_id组合设备的成员

两类设备都绑定计量表、离线表、虚拟表、参数、数据源和命令:

  • tbl_equipments_meters, tbl_equipments_offline_meters, tbl_equipments_virtual_meters, tbl_equipments_parameters, tbl_equipments_data_sources, tbl_equipments_commands
  • tbl_combined_equipments_meters, tbl_combined_equipments_offline_meters, tbl_combined_equipments_virtual_meters, tbl_combined_equipments_parameters, tbl_combined_equipments_data_sources, tbl_combined_equipments_commands

车间、门店和租户​

表关键字段说明
tbl_shopfloorsarea, is_input_counted, is_enabled, contact_id, cost_center_id车间
tbl_storesaddress, latitude, longitude, area, store_type_id, is_input_counted, is_enabled, contact_id, cost_center_id门店
tbl_store_typesname, uuid, simplified_code门店类型
tbl_tenantsbuildings, floors, rooms, area, tenant_type_id, is_input_counted, is_enabled, is_key_tenant, lease_number, lease_start_datetime_utc, lease_end_datetime_utc, is_in_lease, contact_id, cost_center_id租户
tbl_tenant_typesname, uuid, simplified_code租户类型

这三类对象都有计量表、离线表、虚拟表、数据点、传感器、命令和工作日历的关联表。车间还有 tbl_shopfloors_equipments。

光伏电站​

tbl_photovoltaic_power_stations 保存 station_code、address、latitude、longitude、latitude_point_id、longitude_point_id、rated_capacity、rated_power、contact_id、cost_center_id、五个 SVG 槽位(svg_id 到 svg5_id)、is_cost_data_displayed、phase_of_lifecycle 和 commissioning_date。

子表:

表作用
tbl_photovoltaic_power_stations_invertors / _invertors_points逆变器及其数据点
tbl_photovoltaic_power_stations_grids / _grids_points电网连接及其数据点
tbl_photovoltaic_power_stations_loads / _loads_points负荷及其数据点
tbl_photovoltaic_power_stations_data_sources数据源
tbl_photovoltaic_power_stations_users绑定的用户

储能​

tbl_energy_storage_containers 保存 rated_capacity、rated_power、contact_id 和 cost_center_id。部件表及列出的配套 *_points 表:

部件表数据点表
tbl_energy_storage_containers_batteries(soc_point_id、power_point_id、charge_meter_id、discharge_meter_id)—
tbl_energy_storage_containers_power_conversion_systemstbl_energy_storage_containers_pcses_points
—tbl_energy_storage_containers_bmses_points(bms_id、point_id;没有 BMS 主表)
tbl_energy_storage_containers_dcdcstbl_energy_storage_containers_dcdcs_points
tbl_energy_storage_containers_stsestbl_energy_storage_containers_stses_points
tbl_energy_storage_containers_gridstbl_energy_storage_containers_grids_points
tbl_energy_storage_containers_loadstbl_energy_storage_containers_loads_points
tbl_energy_storage_containers_hvacstbl_energy_storage_containers_hvacs_points
tbl_energy_storage_containers_firecontrolstbl_energy_storage_containers_firecontrols_points

另外还有:tbl_energy_storage_containers_commands、tbl_energy_storage_containers_data_sources、tbl_energy_storage_containers_schedules。

tbl_energy_storage_power_stations 使用与光伏电站相同的站点字段(address、坐标、额定容量和功率、联系人、成本中心、五个 SVG、生命周期)。集装箱分组在 tbl_energy_storage_power_stations_containers,用户分组在 tbl_energy_storage_power_stations_users。

微电网​

tbl_microgrids 在站点字段之外增加 postal_code 和 serial_number。子表:

部件数据点
tbl_microgrids_batteries—
—tbl_microgrids_bmses_points(bms_id、point_id;没有 BMS 主表)
tbl_microgrids_power_conversion_systemstbl_microgrids_pcses_points
tbl_microgrids_photovoltaicstbl_microgrids_pvs_points
tbl_microgrids_evchargerstbl_microgrids_evchargers_points
tbl_microgrids_generatorstbl_microgrids_generators_points
tbl_microgrids_gridstbl_microgrids_grids_points
tbl_microgrids_heatpumpstbl_microgrids_heatpumps_points
tbl_microgrids_loadstbl_microgrids_loads_points

另外还有:tbl_microgrids_commands、tbl_microgrids_data_sources、tbl_microgrids_schedules、tbl_microgrids_sensors、tbl_microgrids_users。

其他电站和积分器​

表关键字段说明
tbl_charging_stations地址、坐标、rated_capacity、rated_power、联系人、成本中心、五个 SVG、生命周期充电站
tbl_wind_farms地址、坐标、rated_power、联系人、成本中心、五个 SVG风电场
tbl_virtual_power_plantscost_center_id, balancing_price_point_id, svg_id虚拟电厂
tbl_virtual_power_plants_microgridsvirtual_power_plant_id, microgrid_id虚拟电厂中的微电网
tbl_power_integratorspower_point_id, result_point_id, is_enabled将功率积分成能耗
tbl_fuel_integratorsmodel, power_point_id, result_point_id, is_enabled燃料积分器
tbl_heat_integratorshigh_temperature_point_id, low_temperature_point_id, flow_point_id, heat_capacity, liquid_density, coefficient, result_point_id, is_enabled热量积分器

命令和控制​

表关键字段说明
tbl_commandstopic, payload (LONGTEXT), set_value命令定义
tbl_control_modesname, uuid, is_active控制模式
tbl_control_modes_timescontrol_mode_id, start_time_of_day, end_time_of_day, power_value, power_point_id, power_equation控制模式中的一个时段

费率和排放因子​

表关键字段说明
tbl_tariffsenergy_category_id, tariff_type, unit_of_price, valid_from_datetime_utc, valid_through_datetime_utc费率。tariff_type 为 timeofuse
tbl_tariffs_timeofusestariff_id, start_time_of_day, end_time_of_day, peak_type, price DECIMAL(23, 8)一天中一个时段的价格。peak_type 为 toppeak、onpeak、midpeak、offpeak 或 deep
tbl_cost_centers_tariffscost_center_id, tariff_id费率绑定
tbl_emission_factorsenergy_category_id, unit_of_factor, valid_from_datetime_utc, valid_through_datetime_utc有时间范围的排放因子
tbl_emission_factors_timeofusesemission_factor_id, start_time_of_day, end_time_of_day, factor一天中一个时段的因子
tbl_cost_centers_emission_factorscost_center_id, emission_factor_id因子绑定

图纸、菜单、文件和工单​

表关键字段说明
tbl_distribution_systemsname, uuid, svg_id配电系统
tbl_distribution_circuitsdistribution_system_id, distribution_room, switchgear, peak_load, peak_current, customers, meters回路
tbl_distribution_circuits_pointsdistribution_circuit_id, point_id回路数据点
tbl_energy_flow_diagramsname, uuid能流图
tbl_energy_flow_diagrams_nodesenergy_flow_diagram_id, name节点
tbl_energy_flow_diagrams_linksenergy_flow_diagram_id, source_node_id, target_node_id, meter_uuid连线
tbl_svgsname, uuid, source_code (LONGTEXT)SVG 图形
tbl_menusname, route, parent_menu_id, is_hidden菜单树。没有 uuid
tbl_knowledge_filesfile_name, uuid, upload_datetime_utc, upload_user_uuid, file_object (LONGBLOB)知识库文件
tbl_work_ordersnumber, category, title, priority, status, belong_to_object_type, belong_to_object_id, source_type, source_id, creator_user_id, assignee_user_id,计划时间和实际时间工单
tbl_work_order_logswork_order_id, user_id, action, from_status, to_status, comment, created_datetime_utc状态日志
tbl_work_order_fileswork_order_id, file_name, file_path, file_size, uploaded_by_user_id附件路径。文件字节存放在磁盘上
tbl_versionsversion, release_date模式版本

2. 历史数据库 (myems_historical_db)​

myems_historical_db 保存数据点原始值和上传的工作簿,共 12 张表。

每一类数值都有一张历史表和一张最新值表。历史行包含 is_bad 和 is_published。最新值行只保留 point_id、utc_date_time 和 actual_value。两者都按 (point_id, utc_date_time) 和 utc_date_time 建索引。

表actual_value 类型说明
tbl_analog_value, tbl_analog_value_latestDECIMAL(21, 6)模拟量
tbl_energy_value, tbl_energy_value_latestDECIMAL(21, 6)累计能耗
tbl_digital_value, tbl_digital_value_latestINT数字量
tbl_text_value, tbl_text_value_latestLONGTEXT文本

上传文件共用 file_name、uuid、upload_datetime_utc、status(new、done、error)和 file_object(LONGBLOB):

表用途
tbl_cost_files费用工作簿
tbl_offline_meter_files离线表工作簿
tbl_data_repair_files数据修复工作簿
tbl_energy_plan_files能耗计划工作簿

3. 能耗数据库 (myems_energy_db)​

myems_energy_db 保存小时实际能耗,共 39 张表,没有日、月、年汇总表。报表在查询时把小时向上汇总。

每张表都有 id、父对象 id、start_datetime_utc 和 actual_value DECIMAL(21, 6)。分类表还有 energy_category_id。分项表还有 energy_item_id。组合索引为 (object_id, [分类或分项 id], start_datetime_utc)。

分组表
计量表tbl_meter_hourly, tbl_offline_meter_hourly, tbl_virtual_meter_hourly
设备tbl_equipment_input_category_hourly, tbl_equipment_input_item_hourly, tbl_equipment_output_category_hourly
组合设备tbl_combined_equipment_input_category_hourly, tbl_combined_equipment_input_item_hourly, tbl_combined_equipment_output_category_hourly
空间tbl_space_input_category_hourly, tbl_space_input_item_hourly, tbl_space_output_category_hourly
车间tbl_shopfloor_input_category_hourly, tbl_shopfloor_input_item_hourly
门店tbl_store_input_category_hourly, tbl_store_input_item_hourly
租户tbl_tenant_input_category_hourly, tbl_tenant_input_item_hourly
储能集装箱tbl_energy_storage_container_{charge,discharge,grid_buy,grid_sell,load}_hourly
储能电站tbl_energy_storage_power_station_{charge,discharge,grid_buy,grid_sell,load}_hourly
微电网tbl_microgrid_{charge,discharge,evcharger,grid_buy,grid_sell,load,photovoltaic}_hourly
光伏电站tbl_photovoltaic_power_station_{generation,grid_buy,grid_sell,load}_hourly

计量表、离线表、虚拟表、储能、微电网和光伏电站表没有能源分类列。分类由父对象决定。

4. 费用数据库 (myems_billing_db)​

myems_billing_db 与 myems_energy_db 拥有相同的 39 张小时表和相同的列。actual_value 是费率货币下的费用。计费读取小时能耗以及绑定到成本中心的费率。

5. 碳排放数据库 (myems_carbon_db)​

myems_carbon_db 拥有相同的 39 张小时表。actual_value 是排放量。计算使用小时能耗,以及 tbl_energy_categories.kgco2e 或 tbl_emission_factors 中的分时行。

6. 能耗基准数据库 (myems_energy_baseline_db)​

myems_energy_baseline_db 拥有相同的 39 张小时表。actual_value 是该小时的基准值。

7. 能耗模型数据库 (myems_energy_model_db)​

myems_energy_model_db 拥有相同的 39 组对象。表名以 _8760 结尾,而不是 _hourly,时间列是 hour_of_year(INT),而不是 start_datetime_utc。示例:tbl_meter_8760(meter_id, hour_of_year, actual_value)。

8. 能耗计划数据库 (myems_energy_plan_db)​

myems_energy_plan_db 与 myems_energy_db 拥有相同的 39 张小时表。actual_value 是计划量。计划工作簿先进入 myems_historical_db.tbl_energy_plan_files。

9. 能耗预测数据库 (myems_energy_prediction_db)​

myems_energy_prediction_db 拥有相同的 39 张小时表。actual_value 是预测量。

10. FDD 数据库 (myems_fdd_db)​

myems_fdd_db 有 9 张表。

表关键字段说明
tbl_rulesname, uuid, category, fdd_code, priority, channel, expression, message_template, is_enabled, last_run_datetime_utc, next_run_datetime_utc, is_run_immediately故障规则。expression 为 JSON。message_template 是支持 $ 替换的纯文本
tbl_email_servershost, port, requires_authentication, user_name, password, from_addrSMTP 服务器
tbl_email_messagesrule_id, recipient_email, subject, message, attachment_file_object, scheduled_datetime_utc, status出站邮件
tbl_text_messages_outboxrule_id, recipient_mobile, message, acknowledge_code, status出站短信
tbl_text_messages_inboxsender_mobile, message, received_datetime_utc, status入站短信
tbl_web_messagesrule_id, user_id, subject, category, priority, message, status, reply, belong_to_object_type, belong_to_object_id网页消息
tbl_wechat_configsapi_server, app_id, app_secret, access_token, expires_datetime_utc微信应用
tbl_wechat_messages_outboxrule_id, recipient_openid, message_template_id, message_data, status出站微信消息
tbl_wechat_messages_inboxsender_openid, message, received_datetime_utc, status入站微信消息

tbl_rules.category 取值为 REALTIME、SYSTEM、SPACE、METER、TENANT、STORE、SHOPFLOOR、EQUIPMENT、COMBINEDEQUIPMENT 之一。priority 为 CRITICAL、HIGH、MEDIUM 或 LOW。channel 为 WEB、EMAIL、SMS、WECHAT 或 CALL。fdd_code 标识规则,例如 REALTIME01 或 SPACE02。

11. 用户数据库 (myems_user_db)​

myems_user_db 有 10 张表。

表关键字段说明
tbl_usersname, uuid, display_name, email, phone, salt, password, is_admin, is_read_only, privilege_id, account_expiration_datetime_utc, password_expiration_datetime_utc, failed_login_count用户。password 是加盐哈希(VARCHAR(256))
tbl_privilegesname, data (LONGTEXT, JSON)权限集
tbl_sessionsuser_uuid, token, utc_expires登录会话
tbl_logsuser_uuid, request_datetime_utc, request_method, resource_type, resource_id, request_bodyAPI 审计日志。request_body 为 JSON
tbl_api_keysname, token, created_datetime_utc, expires_datetime_utcAPI 密钥。id 为 INT
tbl_new_usersname, uuid, display_name, email, salt, password待审核注册
tbl_email_messagesrecipient_email, subject, message, scheduled_datetime_utc, status用户邮件,例如重置密码。status 为 new、sent 或 timeout
tbl_email_message_sessionsrecipient_email, token, expires_datetime_utc邮件操作令牌
tbl_verification_codesrecipient_email, verification_code, created_datetime_utc, expires_datetime_utc邮箱验证码。id 为 INT
tbl_notificationsuser_id, created_datetime_utc, status, subject, message, url站内通知。status 为 unread、read 或 archived

12. 报表数据库 (myems_reporting_db)​

myems_reporting_db 有 4 张表。

表关键字段说明
tbl_reportsname, uuid, expression, is_enabled, last_run_datetime_utc, next_run_datetime_utc, is_run_immediately报表计划。expression 为 JSON
tbl_template_filesuuid, report_id, file_name, file_type, file_object绑定到报表的模板
tbl_reports_filesuuid, create_datetime_utc, file_name, file_type, file_object生成的文件
tbl_email_messagesrecipient_email, subject, message, attachment_file_object, scheduled_datetime_utc, status报表投递邮件。此表没有 rule_id

13. 产量数据库 (myems_production_db)​

myems_production_db 有 8 张表。小时产量共用 start_datetime_utc、product_id 和 product_count。

表关键字段说明
tbl_productsname, uuid, unit_of_measure, tag, standard_product_coefficient产品
tbl_teamsname, uuid, description班组
tbl_shopfloors_productsshopfloor_id, product_id车间生产的产品
tbl_shopfloors_teamsshopfloor_id, team_id车间上的班组
tbl_shiftsshopfloor_id, team_id, product_id, product_count, start_datetime_utc, end_datetime_utc, reference_timestamp班次记录
tbl_equipment_hourlyequipment_id, start_datetime_utc, product_id, product_count单台设备的小时产量
tbl_shopfloor_hourlyshopfloor_id, start_datetime_utc, product_id, product_count车间的小时产量
tbl_space_hourlyspace_id, start_datetime_utc, product_id, product_count汇总到空间的小时产量

数据流转关系​

处理顺序:

  1. 网关把数据点值写入 myems_historical_db。上传的工作簿进入同一数据库的文件表。
  2. 规范化根据 tbl_points 的 ratio 和 offset_constant 把数据点值转换成计量表读数。
  3. 汇总为计量表以及每个父对象(设备、空间、门店、租户、车间、储能、微电网、光伏电站)在 myems_energy_db 写入小时行。
  4. 计费用 tbl_tariffs / tbl_tariffs_timeofuses 乘以这些小时值,写入 myems_billing_db。
  5. 碳排放用 kgco2e 或 tbl_emission_factors 乘以这些小时值,写入 myems_carbon_db。
  6. 基准、模型、计划和预测服务写入各自的数据库。模型库保存 hour_of_year,而不是时间戳。
  7. FDD 用 tbl_rules.expression 对照数据点限值和汇总值求值,然后把邮件、短信、网页或微信消息放入队列。
  8. 报表读取能耗、费用和碳排放,填入 tbl_template_files,并把结果存入 tbl_reports_files。
  9. myems_production_db 中的小时产量是能耗强度的分母。

表结构设计规范​

通用字段​

myems_system_db 中的配置表通常包含:

字段类型说明
idBIGINT NOT NULL AUTO_INCREMENT主键
nameVARCHAR(128) 或 VARCHAR(255)显示名称
uuidCHAR(36) NOT NULL稳定的业务键
descriptionVARCHAR(255)可选说明

时间序列表和关联表不遵循这一组字段。事实表使用 id、外键和 actual_value。许多关联表只有 id 和两个外键。tbl_points、tbl_menus 和 tbl_iot_sim_cards 没有 uuid。

数据类型​

用途类型
主键和外键BIGINT(tbl_api_keys 和 tbl_verification_codes 为 INT)
能耗、费用、碳排放、限值、面积DECIMAL(21, 6)
费率时段价格DECIMAL(23, 8)
纬度DECIMAL(12, 10)
经度DECIMAL(13, 10)
时间戳DATETIME,以 UTC 存储
日历日期DATE
一天中的时间TIME
标志BOOL
短代码和状态VARCHAR
JSON 文档(address、faults、definitions、connection、规则和报表的 expression、权限 data、request_body)LONGTEXT
公式(tbl_virtual_meters.equation、power_equation)LONGTEXT
数字量数据点值INT
文件LONGBLOB

索引​

二级索引命名为 {table_name}_index_{n}。

模式示例
按名称查找tbl_meters_index_1 (name)
父对象加时间tbl_meter_hourly_index_1 (meter_id, start_datetime_utc)
分类加时间tbl_space_input_category_hourly_index_1 (space_id, energy_category_id, start_datetime_utc)
数据点历史tbl_analog_value_index_1 (point_id, utc_date_time), tbl_analog_value_index_2 (utc_date_time)
费率有效期tbl_tariffs_index_2 (energy_category_id, valid_from_datetime_utc, valid_through_datetime_utc)

脚本不声明外键。引用完整性由 API 保证。