1# distributeddatamgr\_appdatamgr<a name="EN-US_TOPIC_0000001124534865"></a> 2 3- [Introduction](#section11660541593) 4 - [RDB](#section1589234172717) 5 - [Preferences Database](#section1287582752719) 6 7- [Directory Structure](#section161941989596) 8- [Relational Database](#section101010894114) 9 - [Constraints](#section18387142613414) 10 11- [Preferences Database](#section762641474720) 12 - [Constraints](#section1944481420489) 13 14- [Repositories Involved](#section1371113476307) 15 16## Introduction<a name="section11660541593"></a> 17 18The **relational database \(RDB\)** manages data based on relational models. With the underlying SQLite database, the OpenHarmony RDB provides a complete mechanism for managing local databases. 19 20The **preferences database** provides lightweight key-value operations for local applications to store a small amount of data. As the stored data is already loaded in the memory, the faster data access speed achieves a higher work efficiency. The preferences database is non-relational, and therefore it is not suitable for storing a large amount of data. Instead, the preferences database is usually used to operate data in key-value pairs. 21 22### RDB<a name="section1589234172717"></a> 23 24With the SQLite database as the persistence engine, the OpenHarmony RDB supports all features of the SQLite database , including but not limited to transactions, indices, views, triggers, foreign keys, parameterized queries, and prepared SQL statements. 25 26**Figure 1** How RDB works<a name="fig3330103712254"></a> 27 28 29 30 31### Preferences Database<a name="section1287582752719"></a> 32 331. The preferences database provides operation classes for applications to operate the database. 342. With the **PreferencesHelper**, an app can load the content of a specified file to the **Preferences** instance. Each file has only one **Preferences** instance. The system stores the instance in the memory through a static container until the app removes the instance from the memory or deletes the file. 353. After obtaining the **Preferences** instance, the app can use the functions in **Preferences** to read data from or write data to the **Preferences** instance, and use **flush\(\)** or **flushSync\(\)** to save the modification to the file that stores the preference data. 36 37**Figure 2** How the preferences database works<a name="fig833053712258"></a> 38 39 40 41 42## Directory Structure<a name="section161941989596"></a> 43 44``` 45//foundation/distributeddatamgr/appdatamgr 46├── frameworks # Framework code 47│ └── innerkitsimpl # Internal API implementation 48└── interfaces # APIs 49 └── innerkits # Internal APIs 50``` 51 52## Relational Database<a name="section101010894114"></a> 53 54Some basic concepts are as follows: 55 56- **Relational database \(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### Constraints<a name="section18387142613414"></a> 70 71The RDB can use a maximum of four connection pools to manage read and write operations. 72 73To ensure data accuracy, the RDB supports only one writ operation at a time. 74 75## Preferences Database<a name="section762641474720"></a> 76 77Some basic concepts are as follows: 78 79- **Key-value database** 80 81 A database that stores data in key-value pairs. The **key** indicates keyword, and **value** indicates the corresponding value. 82 83- **Non-relational database** 84 85 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. 86 87- **Preference** **data** 88 89 A type of data that is frequently accessed and used. 90 91 92### Constraints<a name="section1944481420489"></a> 93 94A key should be a string with a maximum of 80 characters and cannot be an empty string. 95 96A value in the format of string can have a maximum of 8192 characters. A value can be an empty string. 97 98To avoid a high memory cost, it is recommended that the preferences database store no more than ten thousand data entries. 99 100## Repositories Involved<a name="section1371113476307"></a> 101 102Distributed Data Management subsystem 103 104distributeddatamgr\_appdatamgr 105 106third\_party\_sqlite 107 108