Go to file
openharmony_ci f75f16c15f
!176 修改循环依赖
Merge pull request !176 from junyi233/master
2022-02-16 04:40:14 +00:00
figures update OpenHarmony 2.0 Canary 2021-06-02 02:57:24 +08:00
frameworks !176 修改循环依赖 2022-02-16 04:40:14 +00:00
interfaces/innerkits change subscribe interface 2022-02-15 12:18:48 +08:00
.clang-format add .clang-format 2021-11-11 17:03:54 +08:00
.gitattributes update OpenHarmony 2.0 Canary 2021-06-02 02:57:24 +08:00
.gitignore I4SBL6: Open interfaces to apply to references 2022-01-27 10:44:08 +08:00
bundle.json !176 修改循环依赖 2022-02-16 04:40:14 +00:00
LICENSE update OpenHarmony 2.0 Canary 2021-06-02 02:57:24 +08:00
OAT.xml update OpenHarmony 2.0 Canary 2021-06-02 02:57:24 +08:00
README_zh.md Signed-off-by: SloveZT <sunpeng26@huawei.com> 2021-06-14 22:56:15 +08:00
README.md update OpenHarmony 2.0 Canary 2021-06-02 02:57:24 +08:00

distributeddatamgr_appdatamgr

Introduction

The 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.

The 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.

RDB

With 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.

Figure 1 How RDB works

Preferences Database

  1. The preferences database provides operation classes for applications to operate the database.
  2. 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.
  3. 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.

Figure 2 How the preferences database works

Directory Structure

//foundation/distributeddatamgr/appdatamgr
├── frameworks            # Framework code
│   └── innerkitsimpl     # Internal API implementation
└── interfaces            # APIs
    └── innerkits         # Internal APIs

Relational Database

Some basic concepts are as follows:

  • Relational database (RDB)

    A database created on the basis of relational models. The RDB stores data in rows and columns.

  • Result set

    A set of query results used to access the data. You can access the required data in a result set in flexible modes.

  • SQLite database

    A lightweight RDB in compliance with the atomicity, consistency, isolation, and durability ACID properties. It is an open-source database.

Constraints

The RDB can use a maximum of four connection pools to manage read and write operations.

To ensure data accuracy, the RDB supports only one writ operation at a time.

Preferences Database

Some basic concepts are as follows:

  • Key-value database

    A database that stores data in key-value pairs. The key indicates keyword, and value indicates the corresponding value.

  • Non-relational database

    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.

  • Preference data

    A type of data that is frequently accessed and used.

Constraints

A key should be a string with a maximum of 80 characters and cannot be an empty string.

A value in the format of string can have a maximum of 8192 characters. A value can be an empty string.

To avoid a high memory cost, it is recommended that the preferences database store no more than ten thousand data entries.

Repositories Involved

Distributed Data Management subsystem

distributeddatamgr_appdatamgr

third_party_sqlite