1# Distributed Data Management<a name="EN-US_TOPIC_0000001096920663"></a> 2 3- [Introduction](#section11660541593) 4- [Directory Structure](#section161941989596) 5- [Usage](#section1312121216216) 6 - [Local Data Management](#section129654513264) 7 - [Distributed Data Service](#section1961602912224) 8 9- [Repositories Involved](#section1371113476307) 10 11## Introduction<a name="section11660541593"></a> 12 13**About the Subsystem** 14 15The Distributed Data Management subsystem can persistently store various structured data of a single device and also supports data synchronization and sharing across devices. In this regard, you can seamlessly integrate distributed application data among different devices, ensuring consistent user experience in the same application across these devices. 16 17- Local data management 18 19 This module allows you to store and access structured data on a single device. It uses the SQLite engine to provide the relational database \(RDB\) and preferences database. With these databases, you can persistently store and access app data using different models. 20 21 22- Distributed data service 23 24 This service can synchronize data across devices, so that users can access consistent data on different devices. DDS isolates data based on a triplet of the account, app, and database. DDS synchronizes data between trusted devices to provide the cross-device data access capability. 25 26 27**Architecture of the Subsystem** 28 29**Figure 1** Architecture<a name="fig4460722185514"></a> 30 31 32 33 34## Directory Structure<a name="section161941989596"></a> 35 36Level 1 and 2 directories of the distributed data management subsystem are as follows: 37 38``` 39distributeddatamgr/ # Distributed data management 40├── appdatamgr # Local data management 41└── distributeddatamgr # Distributed Data Service 42 43third_party/ # Open-source software 44├── flatbuffers # flatbuffers code 45└── sqlite # SQLite code 46``` 47 48## Usage<a name="section1312121216216"></a> 49 50### Local Data Management<a name="section129654513264"></a> 51 52- Relational database \(RDB\) 53 54 Some basic concepts are as follows: 55 56 - **RDB** 57 58 A database created on the basis of relational models. The RDB stores data in rows and columns. 59 60 - **Result set** 61 62 A set of query results used to access the data. You can access the required data in a result set in flexible modes. 63 64 - **SQLite database** 65 66 A lightweight RDB in compliance with the atomicity, consistency, isolation, and durability \(ACID\) properties. It is an open-source database. 67 68 69- Preferences database 70 71 Some basic concepts are as follows: 72 73 - **Key-value database** 74 75 A database that stores data in key-value pairs. The **key** indicates keyword, and **value** indicates the corresponding value. 76 77 - **Non-relational database** 78 79 A database not in compliance with the atomicity, consistency, isolation, and durability \(ACID\) database management properties of relational data transactions. Instead, the data in a non-relational database is independent and scalable. 80 81 - **Preference** **data** 82 83 A type of data that is frequently accessed and used. 84 85 86 87### Distributed Data Service<a name="section1961602912224"></a> 88 89DDS provides apps with the capability to store data in the databases of different devices. It uses the KV data model. 90 91- **KV data model** 92 93 KV is short for key-value. The KV database is a type of NoSQL database. Data in this type of database is organized, indexed, and stored in the form of key-value pairs. 94 95 The KV data model is suitable for storing service data that does not involve too many data or service relationships. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles conflict more easily in database version compatibility and data synchronization. The distributed database is based on the KV data model and provides KV-based access interfaces. 96 97 98## Repositories Involved<a name="section1371113476307"></a> 99 100Distributed Data Management subsystem 101 102distributeddatamgr\_appdatamgr 103 104distributeddatamgr\_distributeddatamgr 105 106third\_party\_sqlite 107 108third\_party\_flatbuffers 109 110