1# 分布式数据管理子系统<a name="ZH-CN_TOPIC_0000001096920663"></a>
2
3- [简介](#section11660541593)
4- [目录](#section161941989596)
5-   [组件说明](#section1312121216216)
6
7    -   [分布式数据对象](#section129654513264)
8    -   [数据共享](#section1961602912223)
9    -   [分布式数据服务](#section1961602912224)
10    -   [Key-Value数据库](#section1961602912225)
11    -   [首选项](#section1961602912226)
12    -   [关系型数据库](#section1961602912227)
13    -   [标准数据化通路](#section1961602912228)
14-   [相关仓](#section1371113476307)
15
16## 简介<a name="section11660541593"></a>
17
18**子系统介绍**
19
20分布式数据管理子系统支持单设备的各种结构化数据的持久化,以及跨设备之间数据的同步、共享功能。开发者通过分布式数据管理子系统,能够方便地完成应用程序数据在不同终端设备间的无缝衔接,满足用户跨设备使用数据的一致性体验。
21
22
23**子系统架构**
24
25**图 1**  子系统架构图<a name="fig4460722185514"></a>
26
27![](figures/数据管理子系统架构图.png)
28
29## 目录<a name="section161941989596"></a>
30
31子系统1-2层目录描述
32
33```
34distributeddatamgr/          # 子系统目录
35├── data_object              # 分布式数据对象目录
36└── data_share               # 数据共享目录
37└── datamgr_service          # 数据服务目录
38└── kv_store                 # Key-Value数据库目录
39└── preferences              # 首选项目录
40└── relational_store         # 关系型数据库目录
41└── udmf                     # 标准化数据通路目录
42
43third_party/                 # 开源软件目录
44├── bounds_checking_function # bounds_checking_function代码目录
45└── cJSON                    # cJSON代码目录
46└── flatbuffers              # flatbuffers代码目录
47└── googletest               # googletest代码目录
48└── jsoncpp                  # jsoncpp代码目录
49└── icu                      # icu代码目录
50└── libuv                    # libuv代码目录
51└── openssl                  # openssl代码目录
52└── sqlite                   # SQLite代码目录
53└── zlib                     # zlib代码目录
54```
55
56## 组件说明<a name="section1312121216216"></a>
57
58### 分布式数据对象<a name="section129654513264"></a>
59
60分布式数据对象管理框架是一款面向对象的内存数据管理框架,向应用开发者提供内存对象的创建、查询、删除、修改、订阅等基本数据对象的管理能力,同时具备分布式能力,满足超级终端场景下,相同应用多设备间的数据对象协同需求。
61
62分布式数据对象提供JS接口,让开发者能以使用本地对象的方式使用分布式对象。分布式数据对象支持的数据类型包括数字型、字符型、布尔型等基本类型,同时也支持数组、基本类型嵌套等复杂类型。
63
64### 数据共享<a name="section1961602912223"></a>
65
66**数据共享(Data Share)** 提供了向其他应用共享以及管理其数据的方法,支持同个设备上不同应用之间的数据共享。
67
68### 分布式数据服务<a name="section1961602912224"></a>
69
70**分布式数据服务(Distributed Data Service,DDS)** 提供不同设备间数据库数据分布式的能力。通过结合帐号、应用和数据库三元组,分布式数据服务对数据进行隔离。在通过可信认证的设备间,分布式数据服务支持数据相互同步,为用户提供在多种终端设备上一致的数据访问体验。
71
72### Key-Value数据库<a name="section1961602912225"></a>
73
74**分布式键值数据库(kv Store)** 为应用程序提供不同设备间数据库的分布式协同能力。通过调用分布式键值数据库各个接口,应用程序可将数据保存到分布式键值数据库中,并可对分布式键值数据库中的数据进行增加、删除、修改、查询、同步等操作。
75
76该模块提供以下分布式键值数据库相关的常用功能:
77
78- [KVManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#kvmanager):分布式键值数据库管理实例,用于获取数据库的相关信息。
79- [KVStoreResultSet](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#kvstoreresultset):提供获取数据库结果集的相关方法,包括查询和移动数据读取位置等。
80- [Query](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#query):使用谓词表示数据库查询,提供创建Query实例、查询数据库中的数据和添加谓词的方法。
81- [SingleKVStore](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#singlekvstore):单版本分布式键值数据库,不对数据所属设备进行区分,提供查询数据和同步数据的方法。
82- [DeviceKVStore](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#devicekvstore):设备协同数据库,继承自[SingleKVStore](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-distributedKVStore.md#singlekvstore),以设备维度对数据进行区分,提供查询数据和同步数据的方法。
83
84### 首选项<a name="section1961602912226"></a>
85
86**首选项(Preferences)** 主要提供轻量级Key-Value操作,支持本地应用存储少量数据,数据存储在本地文件中,同时也加载在内存中,所以访问速度更快,效率更高。首选项提供非关系型数据存储,不宜存储大量数据,经常用于操作键值对形式数据的场景。
87
881.  本模块提供首选项的操作类,应用通过这些操作类完成首选项操作。
892.  借助getPreferences,可以将指定文件的内容加载到Preferences实例,每个文件最多有一个Preferences实例,系统会通过静态容器将该实例存储在内存中,直到主动从内存中移除该实例或者删除该文件。
903.  获取Preferences实例后,可以借助Preferences类的函数,从Preferences实例中读取数据或者将数据写入Preferences实例,通过flush将Preferences实例持久化。
91
92### 关系型数据库<a name="section1961602912227"></a>
93
94**关系型数据库(Relational Database,RDB)** 是一种基于关系模型来管理数据的数据库。OpenHarmony关系型数据库基于SQLite组件提供了一套完整的对本地数据库进行管理的机制。
95
96OpenHarmony关系型数据库底层使用SQLite作为持久化存储引擎,支持SQLite具有的所有数据库特性,包括但不限于事务、索引、视图、触发器、外键、参数化查询和预编译SQL语句。
97
98### 标准化数据通路<a name="section1961602912228"></a>
99
100**标准化数据通路(Unified Data Management Framework,UDMF)** 针对多对多跨应用数据共享的不同业务场景提供了标准化的数据通路,提供了标准化的数据接入与读取接口。同时对文本、图片等数据类型提供了标准化定义,方便不同应用间进行数据交互,减少数据类型适配的工作量。
101
102## 相关仓<a name="section1371113476307"></a>
103
104分布式数据管理子系统
105
106[distributeddatamgr\_data_object](https://gitee.com/openharmony/distributeddatamgr_data_object)
107
108[distributeddatamgr\_data_share](https://gitee.com/openharmony/distributeddatamgr_data_share)
109
110[distributeddatamgr\_datamgr_service](https://gitee.com/openharmony/distributeddatamgr_datamgr_service)
111
112[distributeddatamgr\_kv_store](https://gitee.com/openharmony/distributeddatamgr_kv_store)
113
114[distributeddatamgr\_preferences](https://gitee.com/openharmony/distributeddatamgr_preferences)
115
116[distributeddatamgr\_relational_store](https://gitee.com/openharmony/distributeddatamgr_relational_store)
117
118[distributeddatamgr\_udmf](https://gitee.com/openharmony/distributeddatamgr_udmf)
119
120[third\_party\_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function)
121
122[third\_party\_cJSON](https://gitee.com/openharmony/third_party_cJSON)
123
124[third\_party\_flatbuffers](https://gitee.com/openharmony/third_party_flatbuffers)
125
126[third\_party\_googletest](https://gitee.com/openharmony/third_party_googletest)
127
128[third\_party\_jsoncpp](https://gitee.com/openharmony/third_party_jsoncpp)
129
130[third\_party\_icu](https://gitee.com/openharmony/third_party_icu)
131
132[third\_party\_libuv](https://gitee.com/openharmony/third_party_libuv)
133
134[third\_party\_openssl](https://gitee.com/openharmony/third_party_openssl)
135
136[third\_party\_sqlite](https://gitee.com/openharmony/third_party_sqlite)
137
138[third\_party\_zlib](https://gitee.com/openharmony/third_party_zlib)
139
140