跳到主要內容

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 保證。