CREATE TABLE reports id INTEGER PRIMARY KEY docid
CREATE TABLE reports ( id INTEGER PRIMARY KEY, docid INTEGER, path TEXT, val TEXT ); ■ The attribute ‘id’ is the PRIMARY KEY The ‘id’ is key that can be used to identify each row. INSERT INTO reports (1, 1, ‘/root/title’, ‘report A’); INSERT INTO reports (2, 1, ‘/root/author’, ‘kaneko’); INSERT INTO reports (3, 1, ‘/root/date’, ‘ 2009/11/29’); Table ‘reports’ id docid path val 1 1 /root/title ‘report A’ 2 1 /root/author ‘kaneko’ 3 1 /root/date ‘ 2009/11/29’ created_at 2009 -12 -11 11: 20: 36 PRIMARY KEY Fig. Logical Structure of the Table
Table ‘reports’ id docid 1 2 3 val 1 /root/title ‘report A’ 1 /root/author ‘kaneko’ 1 /root/date ‘ 2009/11/29’ PRIMARY KEY Keys path created_at 2009 -12 -11 11: 20: 36 Logical Structure Associated Records link Record(1, ‘/root/title’, ‘report A’, ‘ 2009 -12 -11 11: 20: 36’) Record(2, ‘/root/author’, ‘kaneko’, ‘ 2009 -12 -11 11: 20: 36’) Record(3, ‘/root/date’, ‘ 2009/11/29’, ‘ 2009 -12 -11 11: 20: 36’) Each key is associated with each record. Physical Structure Fig. Logical Structure and Physical Structure
Record Header Record Database Image
Database Header SQLite Database File
SQLite 3 データベースヘッダ に格納されている情報の例 Page size: 04 00 Database encoding: 00 00 00 ※ UTF-8: 01 little-endian UTF-16: 02 big-endian UTF-16: 03
Keys 1 2 3 Associated Records link Record(1, ‘/root/title’, ‘report A’) Record(2, ‘/root/author’, ‘kaneko’) Record(3, ‘/root/date’, ‘ 2009/11/29’) Each key is associated with each record. Fig. Physical Structure of the Table Record Length (Note that record length is variable) Fig. Database File Layout Example (SQLite 3)
- Slides: 7