70 likes | 245 Vues
CREATE TABLE reports ( id INTEGER PRIMARY KEY , docid INTEGER, path TEXT, val TEXT ); 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’);.
E N D
CREATE TABLE reports ( id INTEGER PRIMARY KEY, docid INTEGER, path TEXT, val TEXT ); 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’); ■ The attribute ‘id’ is the PRIMARY KEY The ‘id’ is key that can be used to identify each row. Table ‘reports’ PRIMARY KEY Fig. Logical Structure of the Table
Table ‘reports’ PRIMARY KEY Logical Structure Associated Records Keys link 1 Record(1, ‘/root/title’, ‘report A’, ‘2009-12-11 11:20:36’) link 2 Record(2, ‘/root/author’, ‘kaneko’, ‘2009-12-11 11:20:36’) link 3 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 Data Database Image
Database Header SQLite Database File
SQLite 3 データベースヘッダ に格納されている情報の例 Page size: 04 00 Database encoding: 00 00 00 01 ※ UTF-8: 01 little-endian UTF-16: 02 big-endian UTF-16: 03
Associated Records Keys link 1 Record(1, ‘/root/title’, ‘report A’) link 2 Record(2, ‘/root/author’, ‘kaneko’) link 3 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)