Skip to content

Commit 3b1fca9

Browse files
authored
Optimization modeling scheme design document (#570)
1 parent 50c86b5 commit 3b1fca9

10 files changed

Lines changed: 378 additions & 12 deletions

File tree

src/.vuepress/sidebar/V2.0.x/zh-Table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const zhSidebar = {
4040
children: [
4141
{ text: '常见概念', link: 'Cluster-Concept_apache' },
4242
{ text: '时序数据模型', link: 'Navigating_Time_Series_Data' },
43-
{ text: '建模方案设计', link: 'Data-Model-and-Terminology' },
43+
{ text: '建模方案设计', link: 'Data-Model-and-Terminology_apache' },
4444
{ text: '数据类型', link: 'Data-Type' },
4545
],
4646
},

src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const zhSidebar = {
4040
children: [
4141
{ text: '常见概念', link: 'Cluster-Concept_timecho' },
4242
{ text: '时序数据模型', link: 'Navigating_Time_Series_Data' },
43-
{ text: '建模方案设计', link: 'Data-Model-and-Terminology' },
43+
{ text: '建模方案设计', link: 'Data-Model-and-Terminology_timecho' },
4444
{ text: '数据类型', link: 'Data-Type' },
4545
],
4646
},
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# 建模方案设计
23+
24+
本章节主要介绍如何将时序数据应用场景转化为IoTDB时序建模。
25+
26+
## 1 时序数据模型
27+
28+
在构建IoTDB建模方案前,需要先了解时序数据和时序数据模型,详细内容见此页面:[时序数据模型](../Background-knowledge/Navigating_Time_Series_Data.md)
29+
30+
## 2 IoTDB 的两种时序模型
31+
32+
> IoTDB 提供了两种数据建模方式——树模型和表模型,其特点分别如下:
33+
34+
**树模型**:以测点为对象进行管理,每个测点对应一条时间序列,测点名按`.`分割可形成一个树形目录结构,与物理世界一一对应,对测点的读写操作简单直观。
35+
36+
**表模型**:推荐为每类设备创建一张表,同类设备的物理量采集都具备一定共性(如都采集温度和湿度物理量),数据分析灵活丰富。
37+
38+
### 2.1 模型特点
39+
40+
两种模型有各自的适用场景。
41+
42+
以下表格从适用场景、典型操作等多个维度对树模型和表模型进行了对比。用户可以根据具体的使用需求,选择适合的模型,从而实现数据的高效存储和管理。
43+
44+
45+
<table style="text-align: center;">
46+
<tr>
47+
<td>对比维度</td>
48+
<td>树模型</td>
49+
<td>表模型</td>
50+
</tr>
51+
<tr>
52+
<td>适用场景</td>
53+
<td>测点管理,监控场景</td>
54+
<td>设备管理,分析场景</td>
55+
</tr>
56+
<tr>
57+
<td>典型操作</td>
58+
<td>指定点位路径进行读写</td>
59+
<td>通过标签进行数据筛选分析</td>
60+
</tr>
61+
<tr>
62+
<td>结构特点</td>
63+
<td>和文件系统一样灵活增删</td>
64+
<td>模板化管理,便于数据治理</td>
65+
</tr>
66+
<tr>
67+
<td>语法特点</td>
68+
<td>简洁</td>
69+
<td>标准</td>
70+
</tr>
71+
<tr>
72+
<td>性能对比</td>
73+
<td colspan="2">相同</td>
74+
</tr>
75+
</table>
76+
77+
**注意:**
78+
- 同一个集群实例中可以存在两种模型空间,不同模型的语法、数据库命名方式不同,默认不互相可见。
79+
80+
- 在通过客户端工具 Cli 或 SDK 建立数据库连接时,需要通过 sql_dialect 参数指定使用的模型语法(默认使用树语法进行操作)。
81+
82+
83+
## 应用场景
84+
85+
应用场景主要包括两类:
86+
87+
- 场景一:使用树模型进行数据的读写
88+
89+
- 场景二:使用表模型进行数据的读写
90+
91+
92+
### 3 场景一:树模型
93+
94+
#### 3.1 特点
95+
96+
- 简单直观,和物理世界的监测点位一一对应
97+
98+
- 类似文件系统一样灵活,可以设计任意分支结构
99+
100+
- 适用 DCS、SCADA 等工业监控场景
101+
102+
#### 3.2 基础概念
103+
104+
| **概念** | **定义** |
105+
| -------------------- | ------------------------------------------------------------ |
106+
| **数据库** | 定义:一个以 root. 为前缀的路径<br>命名推荐:仅包含 root 的下一级节点,如 root.db<br>数量推荐:上限和内存相关,一个数据库也可以充分利用机器资源,无需为性能原因创建多个数据库<br>创建方式:推荐手动创建,也可创建时间序列时自动创建(默认为 root 的下一级节点) |
107+
| **时间序列(测点)** | 定义:<br>1. 一个以数据库路径为前缀的、由 . 分割的路径,可包含任意多个层级,如 root.db.turbine.device1.metric1 <br>2. 每个时间序列可以有不同的数据类型。<br>命名推荐:<br>1. 仅将唯一定位时间序列的标签(类似联合主键)放入路径中,一般不超过10层<br>2. 通常将基数(不同的取值数量)少的标签放在前面,便于系统将公共前缀进行压缩<br>数量推荐:<br>1. 集群可管理的时间序列总量和总内存相关,可参考资源推荐章节<br>2. 任一层级的子节点数量没有限制<br>创建方式:可手动创建或在数据写入时自动创建。 |
108+
| **设备** | 定义:倒数第二级为设备,如 root.db.turbine.**device1**.metric1中的“device1”这一层级即为设备<br>创建方式:无法仅创建设备,随时间序列创建而存在 |
109+
110+
#### 3.3 建模示例
111+
112+
##### 3.3.1 有多种类型的设备需要管理,如何建模?
113+
114+
- 如场景中不同类型的设备具备不同的层级路径和测点集合,可以在数据库节点下按设备类型创建分支。每种设备下可以有不同的测点结构。
115+
116+
<div style="text-align: center;">
117+
<img src="/img/Modeling-scheme04.png" alt="" style="width: 70%;"/>
118+
</div>
119+
120+
##### 3.3.2 如果场景中没有设备,只有测点,如何建模?
121+
122+
- 如场站的监控系统中,每个测点都有唯一编号,但无法对应到某些设备。
123+
124+
<div style="text-align: center;">
125+
<img src="/img/data-modeling04.png" alt="" style="width: 70%;"/>
126+
</div>
127+
128+
##### 3.3.3 如果在一个设备下,既有子设备,也有测点,如何建模?
129+
130+
- 如在储能场景中,每一层结构都要监控其电压和电流,可以采用如下建模方式。
131+
132+
<div style="text-align: center;">
133+
<img src="/img/Modeling-scheme05.png" alt="" style="width: 70%;"/>
134+
</div>
135+
136+
137+
### 4 场景二:表模型
138+
139+
#### 4.1 特点
140+
141+
- 以时序表建模管理设备时序数据,便于使用标准 SQL 进行分析
142+
143+
- 适用于设备数据分析或从其他数据库迁移至 IoTDB 的场景
144+
145+
#### 4.2 基础概念
146+
147+
- 数据库:可管理多类设备
148+
149+
- 时序表:对应一类设备
150+
151+
| **列类别** | **定义** |
152+
| --------------------------- | ------------------------------------------------------------ |
153+
| **时间列(TIME)** | 每个时序表必须有一个时间列,且列名必须为 time,数据类型为 TIMESTAMP |
154+
| **标签列(TAG)** | 设备的唯一标识(联合主键),可以为 0 至多个<br>标签信息不可修改和删除,但允许增加<br>推荐按粒度由大到小进行排列 |
155+
| **测点列(FIELD)** | 一个设备采集的测点可以有1个至多个,值随时间变化<br>表的测点列没有数量限制,可以达到数十万以上 |
156+
| **属性列(ATTRIBUTE)** | 对设备的补充描述,**不随时间变化**<br>设备属性信息可以有0个或多个,可以更新或新增<br>少量希望修改的静态属性可以存至此列 |
157+
158+
159+
数据筛选效率:时间列=标签列>属性列>测点列
160+
161+
#### 4.3 建模示例
162+
163+
##### 4.3.1 有多种类型的设备需要管理,如何建模?
164+
165+
- 推荐为每一类型的设备建立一张表,每个表可以具有不同的标签和测点集合。
166+
- 即使设备之间有联系,或有层级关系,也推荐为每一类设备建一张表。
167+
168+
<div style="text-align: center;">
169+
<img src="/img/data-modeling06.png" alt="" style="width: 70%;"/>
170+
</div>
171+
172+
##### 4.3.2 如果没有设备标识列和属性列,如何建模?
173+
174+
- 列数没有数量限制,可以达到数十万以上。
175+
176+
<div style="text-align: center;">
177+
<img src="/img/data-modeling07.png" alt="" style="width: 70%;"/>
178+
</div>
179+
180+
##### 4.3.3 如果在一个设备下,既有子设备,也有测点,如何建模?
181+
182+
- 每个设备有多个子设备及测点信息,推荐为每类设备建一个表进行管理。
183+
184+
<div style="text-align: center;">
185+
<img src="/img/Modeling-scheme06.png" alt="" style="width: 70%;"/>
186+
</div>

src/zh/UserGuide/Master/Table/Background-knowledge/Data-Model-and-Terminology.md renamed to src/zh/UserGuide/Master/Table/Background-knowledge/Data-Model-and-Terminology_timecho.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@
9090

9191
- 场景三:共用一份数据,使用树模型进行数据读写、使用表模型进行数据分析
9292

93-
![](/img/%E5%BB%BA%E6%A8%A1%E6%96%B9%E6%A1%88%E8%AE%BE%E8%AE%A101.png)
94-
95-
9693
### 3 场景一:树模型
9794

9895
#### 3.1 特点

src/zh/UserGuide/Master/Table/QuickStart/QuickStart_apache.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
- 时序概念介绍:[时序数据模型](../Background-knowledge/Navigating_Time_Series_Data.md)
4949

50-
- 建模设计介绍:[建模方案设计](../Background-knowledge/Data-Model-and-Terminology.md)
50+
- 建模设计介绍:[建模方案设计](../Background-knowledge/Data-Model-and-Terminology_apache.md)
5151

5252
- 数据库介绍:[数据库管理](../Basic-Concept/Database-Management.md)
5353

src/zh/UserGuide/Master/Table/QuickStart/QuickStart_timecho.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
- 时序概念介绍:[时序数据模型](../Background-knowledge/Navigating_Time_Series_Data.md)
5656

57-
- 建模设计介绍:[建模方案设计](../Background-knowledge/Data-Model-and-Terminology.md)
57+
- 建模设计介绍:[建模方案设计](../Background-knowledge/Data-Model-and-Terminology_timecho.md)
5858

5959
- 数据库介绍:[数据库管理](../Basic-Concept/Database-Management.md)
6060

0 commit comments

Comments
 (0)