What Is SQLite

Summary: This tutorial gives you a brief overview of SQLite and the SQLite’s distinctive features that make SQLite the most widely deployed SQL database engine.

What is SQLite


SQLite is a software library that provides a relational database management system. The lite in SQLite means lightweight in terms of setup, database administration, and required resources.

SQLite has the following noticeable features: self-contained, serverless, zero-configuration, transactional.

Serverless


Normally, an RDBMS such as MySQL, PostgreSQL, etc., requires a separate server process to operate. The applications that want to access the database server use TCP/IP protocol to send and receive requests. This is called client/server architecture.

The following diagram illustrates the RDBMS client/server architecture:
SQLite does NOT work this way.

SQLite does NOT require a server to run.

SQLite database is integrated with the application that accesses the database. The applications interact with the SQLite database read and write directly from the database files stored on disk.

The following diagram illustrates the SQLite server-less architecture:

Self-Contained


SQLite is self-contained means it requires minimal support from the operating system or external library. This makes SQLite usable in any environment especially in embedded devices like iPhones, Android phones, game consoles, handheld media players, etc.

SQLite is developed using ANSI-C. The source code is available as a big sqlite3.c and its header file sqlite3.h. If you want to develop an application that uses SQLite, you just need to drop these files into your project and compile it with your code.

Zero-configuration


Because of the serverless architecture, you don’t need to “install” SQLite before using it. There is no server process that needs to be configured, started, and stopped.

In addition, SQLite does not use any configuration files.

Transactional


All transactions in SQLite are fully ACID-compliant. It means all queries and changes are Atomic, Consistent, Isolated, and Durable.

In other words, all changes within a transaction take place completely or not at all even when an unexpected situation like application crash, power failure, or operating system crash occurs.

SQLite distinctive features


SQLite uses dynamic types for tables. It means you can store any value in any column, regardless of the data type.

SQLite allows a single database connection to access multiple database files simultaneously. This brings many nice features like joining tables in different databases or copying data between databases in a single command.

SQLite is capable of creating in-memory databases that are very fast to work with.


概要:このチュートリアルでは、SQLiteの概要と、SQLiteが最も広く導入されているSQLデータベースエンジンとなっている、SQLiteの特徴的な機能について説明します。
SQLiteとは
SQLiteは、リレーショナルデータベース管理システムを提供するソフトウェアライブラリです。SQLiteのliteとは、セットアップやデータベース管理、必要なリソースなどの面で軽量であることを意味します。
SQLiteには、自己完結型、サーバーレス型、ゼロコンフィギュレーション型、トランザクション型といった顕著な特徴があります。
サーバーレス
通常、MySQLやPostgreSQLなどのRDBMSは、動作させるために別途サーバープロセスを必要とします。データベースサーバーにアクセスしたいアプリケーションは、TCP/IPプロトコルを使ってリクエストを送受信します。これをクライアント/サーバー・アーキテクチャと呼びます。
次の図は、RDBMSのクライアント/サーバー・アーキテクチャを示しています。
SQLite はこのようには動作しません。
SQLite はこのようには動作しません。SQLite は動作にサーバーを必要としません。
SQLite のデータベースは、そのデータベースにアクセスするアプリケーションと一体化しています。SQLite データベースは、データベースにアクセスするアプリケーションと統合されており、アプリケーションは、ディスク上に保存されているデータベースファイルから直接読み書きを行います。
次の図は、SQLite のサーバーレスアーキテクチャを示しています。
自己完結型
SQLiteが自己完結型であるということは、オペレーティングシステムや外部ライブラリからのサポートが最小限で済むことを意味します。このため、SQLiteはあらゆる環境で使用することができ、特にiPhoneやAndroid携帯、ゲーム機、ハンドヘルドメディアプレーヤーなどの組み込み機器で使用することができます。
SQLiteは、ANSI-Cで開発されています。ソースコードは、大きなsqlite3.cとそのヘッダーファイルsqlite3.hとして提供されています。SQLiteを使用するアプリケーションを開発したい場合は、これらのファイルをプロジェクトにドロップして、コードと一緒にコンパイルするだけです。
ゼロコンフィグレーション
サーバーレスアーキテクチャを採用しているため、SQLiteを使用する前に「インストール」する必要はありません。設定、起動、停止が必要なサーバープロセスはありません。
また、SQLiteは設定ファイルを一切使用しません。
トランザクション
SQLiteのすべてのトランザクションは、完全にACIDに準拠しています。これは、すべてのクエリと変更が、Atomic(原子)、Consistent(一貫性)、Isolated(隔離)、Durable(耐久性)であることを意味します。
言い換えれば、アプリケーションのクラッシュ、電源障害、オペレーティングシステムのクラッシュなどの不測の事態が発生しても、トランザクション内のすべての変更は完全に行われるか、まったく行われないということです。
SQLiteの特徴的な機能
SQLiteはテーブルに動的型を採用しています。これは、データ型に関係なく、どのカラムにも任意の値を格納できることを意味します。
SQLiteでは、1つのデータベース接続で複数のデータベースファイルに同時にアクセスすることができます。これにより、異なるデータベースのテーブルを結合したり、1つのコマンドでデータベース間のデータをコピーするなど、多くの素晴らしい機能がもたらされます。
SQLiteは、非常に高速に動作するインメモリデータベースを作成することができます。

この記事が気に入ったらサポートをしてみませんか?