Skip to content

Commit 0e226d5

Browse files
committed
add basic concept in table management
1 parent 21992cc commit 0e226d5

8 files changed

Lines changed: 375 additions & 98 deletions

File tree

src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,49 @@
2121

2222
# Table Management
2323

24-
Before starting to use the table management functionality, we recommend familiarizing yourself with the following related background knowledge for a better understanding and application of the table management features:
25-
* [Timeseries Data Model](../Background-knowledge/Navigating_Time_Series_Data_apache.md): Understand the basic concepts and characteristics of time series data to establish a foundation for data modeling.
26-
* [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_apache.md): Master the IoTDB time series model and its applicable scenarios to provide a design basis for table management.
24+
In the table model, it is recommended that one table corresponds to one type of device, for managing time series data of such devices. Devices of the same type usually have the same or similar set of measurement points, such as wind turbines, vehicles, production equipment or monitoring objects of the same category.
2725

28-
## 1. Table Management
26+
## 1. Basic Concepts
2927

30-
### 1.1 Create a Table
28+
### 1.1 Table
3129

32-
#### 1.1.1 Manually create a table with CREATE
30+
Tables are generally used to store time series data for the same type of device. During data modeling, device identification information can be designed as TAG columns, static device descriptions as ATTRIBUTE columns, and time-varying collected values as FIELD columns.
31+
32+
### 1.2 Time Column, Tag Column, Attribute Column and Measurement Column
33+
34+
![](/img/sample-dataset-en-01.png)
35+
36+
The table structure in the table model is generally shown in the figure above. Columns can be classified into the following categories by purpose:
37+
38+
| Concept | Description |
39+
| ------- | ----------- |
40+
| Time Column (TIME) | Each table must contain one time column of the TIMESTAMP data type, which records the timestamp corresponding to each data point. |
41+
| Tag Column (TAG) | Used to identify devices and can serve as the composite primary key of a device. It typically stores information for locating devices, such as region, plant, and device ID. Values in tag columns usually do not change over time. |
42+
| Attribute Column (ATTRIBUTE) | Used to describe static attributes of a device, such as model, manufacturer, and maintenance information. Attribute columns do not change over time and can be added or updated. |
43+
| Measurement Column (FIELD) | Used to store physical quantities or metrics collected from devices, whose values change over time, such as temperature, humidity, current, voltage, and status. |
44+
45+
In terms of query filtering efficiency, the general priority order is: time column and tag columns first, followed by attribute columns, and measurement columns last.
46+
47+
### 1.3 Devices and Measurement Points
48+
49+
In the table model, a device is uniquely identified by the combination of values from all TAG columns in a table. For example, if a table contains three TAG columns: `region`, `plant_id`, and `device_id`, each unique combination of `region + plant_id + device_id` represents an independent device.
50+
51+
Measurement points correspond to FIELD columns in the table. One FIELD column for a single device generates multiple data points over time, and these time-ordered data points form a time series.
52+
53+
Therefore, the number of measurement points per table in the table model can be expressed by the following formula:
54+
`Number of measurement points per table = Number of devices × Number of FIELD columns`
55+
56+
### 1.4 Table-Level TTL
57+
58+
The TTL of a table defaults to the TTL of its parent database. If a table is configured with a separate TTL, the table-level TTL takes precedence. Proper use of table-level TTL allows different data retention periods to be set for different business tables.
59+
60+
For a more detailed introduction to TTL features, see: [TTL Delete Data](../Basic-Concept/TTL-Delete-Data_apache.md)
61+
62+
For further information on the IoTDB tree-table twin model, model selection methods and typical modeling solutions, please refer to [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_apache.md).
63+
64+
## 2. Table Management
65+
66+
### 2.1 Create a Table
3367

3468
Manually create a table within the current or specified database.The format is "database name. table name".
3569

@@ -111,7 +145,7 @@ CREATE TABLE table1 (
111145

112146
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.
113147

114-
### 1.2 View Tables
148+
### 2.2 View Tables
115149

116150
Used to view all tables and their properties in the current or a specified database.
117151

@@ -143,7 +177,7 @@ show tables details from database1;
143177
+---------------+-----------+------+-------+
144178
```
145179

146-
### 1.3 View Table Columns
180+
### 2.3 View Table Columns
147181

148182
Used to view column names, data types, categories, and states of a table.
149183

@@ -183,7 +217,7 @@ desc table1 details;
183217
```
184218

185219

186-
### 1.4 View Table Creation Statement
220+
### 2.4 View Table Creation Statement
187221

188222
Retrieves the complete definition statement of a table or view under the table model. This feature automatically fills in all default values that were omitted during creation, so the displayed statement may differ from the original CREATE statement.
189223

@@ -213,7 +247,7 @@ show create table table1;
213247
```
214248

215249

216-
### 1.5 Update Tables
250+
### 2.5 Update Tables
217251

218252
Used to update a table, including adding or deleting columns and configuring table properties.
219253

@@ -254,7 +288,7 @@ COMMENT ON TABLE table1 IS 'table1';
254288
COMMENT ON COLUMN table1.a IS null;
255289
```
256290

257-
### 1.6 Delete Tables
291+
### 2.6 Delete Tables
258292

259293
Used to delete a table.
260294

src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,51 @@
2020
-->
2121

2222
# Table Management
23+
24+
In the table model, it is recommended that one table corresponds to one type of device, for managing time series data of such devices. Devices of the same type usually have the same or similar set of measurement points, such as wind turbines, vehicles, production equipment or monitoring objects of the same category.
2325

24-
Before starting to use the table management functionality, we recommend familiarizing yourself with the following related background knowledge for a better understanding and application of the table management features:
25-
* [Timeseries Data Model](../Background-knowledge/Navigating_Time_Series_Data_timecho.md): Understand the basic concepts and characteristics of time series data to establish a foundation for data modeling.
26-
* [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_timecho.md): Master the IoTDB time series model and its applicable scenarios to provide a design basis for table management.
26+
## 1. Basic Concepts
2727

28-
## 1. Table Management
28+
### 1.1 Table
2929

30-
### 1.1 Create a Table
30+
Tables are generally used to store time series data for the same type of device. During data modeling, device identification information can be designed as TAG columns, static device descriptions as ATTRIBUTE columns, and time-varying collected values as FIELD columns.
3131

32-
#### 1.1.1 Manually create a table with CREATE
32+
### 1.2 Time Column, Tag Column, Attribute Column and Measurement Column
33+
34+
![](/img/sample-dataset-en-01.png)
35+
36+
The table structure in the table model is generally shown in the figure above. Columns can be classified into the following categories by purpose:
37+
38+
| Concept | Description |
39+
| ------- | ----------- |
40+
| Time Column (TIME) | Each table must contain one time column of the TIMESTAMP data type, which records the timestamp corresponding to each data point. |
41+
| Tag Column (TAG) | Used to identify devices and can serve as the composite primary key of a device. It typically stores information for locating devices, such as region, plant, and device ID. Values in tag columns usually do not change over time. |
42+
| Attribute Column (ATTRIBUTE) | Used to describe static attributes of a device, such as model, manufacturer, and maintenance information. Attribute columns do not change over time and can be added or updated. |
43+
| Measurement Column (FIELD) | Used to store physical quantities or metrics collected from devices, whose values change over time, such as temperature, humidity, current, voltage, and status. |
44+
45+
In terms of query filtering efficiency, the general priority order is: time column and tag columns first, followed by attribute columns, and measurement columns last.
46+
47+
### 1.3 Devices and Measurement Points
48+
49+
In the table model, a device is uniquely identified by the combination of values from all TAG columns in a table. For example, if a table contains three TAG columns: `region`, `plant_id`, and `device_id`, each unique combination of `region + plant_id + device_id` represents an independent device.
50+
51+
Measurement points correspond to FIELD columns in the table. One FIELD column for a single device generates multiple data points over time, and these time-ordered data points form a time series.
52+
53+
Therefore, the number of measurement points per table in the table model can be expressed by the following formula:
54+
`Number of measurement points per table = Number of devices × Number of FIELD columns`
55+
For the specific calculation process, please refer to Section 2.7 *Metadata Query*.
56+
57+
### 1.4 Table-Level TTL
58+
59+
The TTL of a table defaults to the TTL of its parent database. If a table is configured with a separate TTL, the table-level TTL takes precedence. Proper use of table-level TTL allows different data retention periods to be set for different business tables.
60+
61+
For a more detailed introduction to TTL features, see: [TTL Delete Data](../Basic-Concept/TTL-Delete-Data_timecho.md)
62+
63+
For further information on the IoTDB tree-table twin model, model selection methods and typical modeling solutions, please refer to [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_timecho.md).
64+
65+
## 2. Table Management
66+
67+
### 2.1 Create a Table
3368

3469
Manually create a table within the current or specified database.The format is "database name. table name".
3570

@@ -111,7 +146,7 @@ CREATE TABLE table1 (
111146

112147
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.
113148

114-
### 1.2 View Tables
149+
### 2.2 View Tables
115150

116151
Used to view all tables and their properties in the current or a specified database.
117152

@@ -143,7 +178,7 @@ show tables details from database1;
143178
+---------------+-----------+------+-------+
144179
```
145180

146-
### 1.3 View Table Columns
181+
### 2.3 View Table Columns
147182

148183
Used to view column names, data types, categories, and states of a table.
149184

@@ -182,7 +217,7 @@ desc table1 details;
182217
+------------+---------+---------+------+------------+
183218
```
184219

185-
### 1.4 View Table Creation Statement
220+
### 2.4 View Table Creation Statement
186221

187222
Retrieves the complete definition statement of a table or view under the table model. This feature automatically fills in all default values that were omitted during creation, so the displayed statement may differ from the original CREATE statement.
188223

@@ -213,7 +248,7 @@ Total line number = 1
213248
```
214249

215250

216-
### 1.5 Update Tables
251+
### 2.5 Update Tables
217252

218253
Used to update a table, including adding or deleting columns, modify column type (V2.0.8.2) and configuring table properties.
219254

@@ -264,7 +299,7 @@ alter column datatype
264299
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE;
265300
```
266301

267-
### 1.6 Delete Tables
302+
### 2.6 Delete Tables
268303

269304
Used to delete a table.
270305

@@ -281,7 +316,7 @@ DROP TABLE table1;
281316
DROP TABLE database1.table1;
282317
```
283318

284-
## 1.7 Metadata Query
319+
### 2.7 Metadata Query
285320
Under the table model, the **total number of measurement points** equals the sum of measurement points of all tables. Currently, the number of measurement points in a single table can be calculated with the formula:
286321
**Measurement points per single table = Number of devices × Number of field columns**.
287322
Support for directly querying measurement points under the table model via SQL statements will be available in future updates. Please stay tuned.
@@ -301,7 +336,8 @@ The sample data defines 2 regions: Beijing and Shanghai. Details are as follows:
301336

302337
In total, there are 6 unique tag combinations in the table, corresponding to 6 independent devices.
303338

304-
### Complete Calculation Example for Single-Table Measurement Points
339+
**Complete Calculation Example for Single-Table Measurement Points**
340+
305341
1. Query the number of devices
306342
```sql
307343
IoTDB:database1> count devices from table1;

src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,49 @@
2121

2222
# Table Management
2323

24-
Before starting to use the table management functionality, we recommend familiarizing yourself with the following related background knowledge for a better understanding and application of the table management features:
25-
* [Timeseries Data Model](../Background-knowledge/Navigating_Time_Series_Data_apache.md): Understand the basic concepts and characteristics of time series data to establish a foundation for data modeling.
26-
* [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_apache.md): Master the IoTDB time series model and its applicable scenarios to provide a design basis for table management.
24+
In the table model, it is recommended that one table corresponds to one type of device, for managing time series data of such devices. Devices of the same type usually have the same or similar set of measurement points, such as wind turbines, vehicles, production equipment or monitoring objects of the same category.
2725

28-
## 1. Table Management
26+
## 1. Basic Concepts
2927

30-
### 1.1 Create a Table
28+
### 1.1 Table
3129

32-
#### 1.1.1 Manually create a table with CREATE
30+
Tables are generally used to store time series data for the same type of device. During data modeling, device identification information can be designed as TAG columns, static device descriptions as ATTRIBUTE columns, and time-varying collected values as FIELD columns.
31+
32+
### 1.2 Time Column, Tag Column, Attribute Column and Measurement Column
33+
34+
![](/img/sample-dataset-en-01.png)
35+
36+
The table structure in the table model is generally shown in the figure above. Columns can be classified into the following categories by purpose:
37+
38+
| Concept | Description |
39+
| ------- | ----------- |
40+
| Time Column (TIME) | Each table must contain one time column of the TIMESTAMP data type, which records the timestamp corresponding to each data point. |
41+
| Tag Column (TAG) | Used to identify devices and can serve as the composite primary key of a device. It typically stores information for locating devices, such as region, plant, and device ID. Values in tag columns usually do not change over time. |
42+
| Attribute Column (ATTRIBUTE) | Used to describe static attributes of a device, such as model, manufacturer, and maintenance information. Attribute columns do not change over time and can be added or updated. |
43+
| Measurement Column (FIELD) | Used to store physical quantities or metrics collected from devices, whose values change over time, such as temperature, humidity, current, voltage, and status. |
44+
45+
In terms of query filtering efficiency, the general priority order is: time column and tag columns first, followed by attribute columns, and measurement columns last.
46+
47+
### 1.3 Devices and Measurement Points
48+
49+
In the table model, a device is uniquely identified by the combination of values from all TAG columns in a table. For example, if a table contains three TAG columns: `region`, `plant_id`, and `device_id`, each unique combination of `region + plant_id + device_id` represents an independent device.
50+
51+
Measurement points correspond to FIELD columns in the table. One FIELD column for a single device generates multiple data points over time, and these time-ordered data points form a time series.
52+
53+
Therefore, the number of measurement points per table in the table model can be expressed by the following formula:
54+
`Number of measurement points per table = Number of devices × Number of FIELD columns`
55+
56+
### 1.4 Table-Level TTL
57+
58+
The TTL of a table defaults to the TTL of its parent database. If a table is configured with a separate TTL, the table-level TTL takes precedence. Proper use of table-level TTL allows different data retention periods to be set for different business tables.
59+
60+
For a more detailed introduction to TTL features, see: [TTL Delete Data](../Basic-Concept/TTL-Delete-Data_apache.md)
61+
62+
For further information on the IoTDB tree-table twin model, model selection methods and typical modeling solutions, please refer to [Modeling Scheme Design](../Background-knowledge/Data-Model-and-Terminology_apache.md).
63+
64+
## 2. Table Management
65+
66+
### 2.1 Create a Table
3367

3468
Manually create a table within the current or specified database.The format is "database name. table name".
3569

@@ -111,7 +145,7 @@ CREATE TABLE table1 (
111145

112146
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.
113147

114-
### 1.2 View Tables
148+
### 2.2 View Tables
115149

116150
Used to view all tables and their properties in the current or a specified database.
117151

@@ -143,7 +177,7 @@ show tables details from database1;
143177
+---------------+-----------+------+-------+
144178
```
145179

146-
### 1.3 View Table Columns
180+
### 2.3 View Table Columns
147181

148182
Used to view column names, data types, categories, and states of a table.
149183

@@ -183,7 +217,7 @@ desc table1 details;
183217
```
184218

185219

186-
### 1.4 View Table Creation Statement
220+
### 2.4 View Table Creation Statement
187221

188222
Retrieves the complete definition statement of a table or view under the table model. This feature automatically fills in all default values that were omitted during creation, so the displayed statement may differ from the original CREATE statement.
189223

@@ -213,7 +247,7 @@ show create table table1;
213247
```
214248

215249

216-
### 1.5 Update Tables
250+
### 2.5 Update Tables
217251

218252
Used to update a table, including adding or deleting columns and configuring table properties.
219253

@@ -254,7 +288,7 @@ COMMENT ON TABLE table1 IS 'table1';
254288
COMMENT ON COLUMN table1.a IS null;
255289
```
256290

257-
### 1.6 Delete Tables
291+
### 2.6 Delete Tables
258292

259293
Used to delete a table.
260294

0 commit comments

Comments
 (0)