Android Development note "SQLite"

Source: Internet
Author: User

Introduction and analysis of SQLite

1. Introduction to SQLite

Since the advent of business applications decades ago, databases have become a major component of software applications. are very critical to database management systems, they are also very large and occupy a considerable amount of system resources, increasing the complexity of management. As software applications become modular, a new type of database is more adaptable than a large and complex traditional database management system. The embedded database runs directly in the application process, provides a 0 configuration (zero-configuration) run mode, and consumes very little resources.
SQLite is an open source embedded relational database, released in 2000 by D.richard Hipp, which reduces the overhead of application management data, SQLite portability, is easy to use, small, efficient and reliable.
SQLite is embedded in applications that use it, and they share the same process space instead of a single process. Externally, it's not like an RDBMS, but inside the process it's a complete, self-contained database engine.

One of the great benefits of an embedded database is that you don't need a network configuration or management within your program. Because the client and the server are running in the same process space. SQLite's database permissions depend only on the file system, without the concept of a user account. SQLite has a database-level lock and no network server. It requires less memory, other overhead, and is suitable for use in embedded devices. All you need to do is to compile it correctly into your program.

2. Architecture (architecture)

SQLite uses the design of the module, which consists of three subsystems, including 8 separate modules.

2.1. Interface (Interface)
The interface is made up of the SQLite C API, that is, whether it is a program, a scripting language, or a library file, and ultimately it interacts with SQLite through it (the ODBC/JDBC we typically use more often will eventually be translated into the corresponding C API calls).

2.2. Compiler (Compiler)
In the compiler, the word breaker (tokenizer) and the parser (Parser) Check the SQL syntax, and then convert it into a layered data structure that is more easily handled by the underlying---syntax tree, and then pass the syntax tree to the code generator for processing. The code generator generates an assembly code for SQLite based on it, which is then executed by the virtual machine (virtualmachine).

2.3. Virtual machine
The most central part of the architecture is the virtual machine, or virtual database engine (ENGINE,VDBE). It is similar to the Java Virtual machine and interprets the execution byte code. The byte code of the VDBE is comprised of 128 opcode (opcodes), which are mainly focused on database operations. Each of its instructions is used to complete specific database operations (such as opening a table's cursor) or for the preparation of these stack spaces (such as a push-in parameter). In summary, all of these directives are intended to meet the requirements of the SQL command (for VMS, which are described in more detail later).

2.4, back end (Back-end)
After driven by B-tree (b-tree), page cache (Pagecache,pager) and operating system interfaces (i.e. system calls) constitute. B-tree and page cache work together to manage the data. The main function of B-tree is indexing, which maintains a complex relationship between pages, making it easy to find the data you need quickly. The main function of pager is to pass the page between B-tree and disk through the OS interface.

3, the characteristics of SQLite (SQLite's Features andphilosophy)
3.1, 0 configurations (Zero configuration)
3.2. Portable (portability):
It is an AIX running on Windows,linux,bsd,mac OS X and some commercial UNIX systems, such as Sun's SOLARIS,IBM, and it can also work on many embedded operating systems, such as the Qnx,vxworks,palm OS, Symbin and Windows CE.
3.3, compactness:
SQLite is designed to be lightweight and self-contained. One header file, one library, and you ' rerelational, no external database server required
3.4. Simple (simplicity)
3.5. Flexible (flexibility)
3.6, Reliable (reliability):
The core of SQLite is about 30,000 lines of standard C code, which are modular and easy to read.

SQLite Learning Address: http://www.sqlite.com.cn/MySqlite/4/535.Html

Android Development note "SQLite"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.