Extend local database once more.
[cumulus.git] / schema.sql
1 -- We maintain a local index of data blocks that have been previously stored
2 -- for constructing incremental snapshots.
3 --
4 -- The index is stored in an SQLite3 database.  This is its schema.
5
6 -- List of snapshots which have been created.
7 create table snapshots (
8     snapshotid integer primary key,
9     name text not null,
10     timestamp real
11 );
12
13 -- List of segments which have been created.
14 create table segments (
15     segmentid integer primary key,
16     segment text unique not null
17 );
18
19 -- Index of all blocks which have been stored in a snapshot, by checksum.
20 create table block_index (
21     blockid integer primary key,
22     segmentid integer not null,
23     object text not null,
24     checksum text,
25     size integer,
26     timestamp real,
27     expired integer
28 );
29 create index block_content_index on block_index(checksum);
30 create unique index block_name_index on block_index(segmentid, object);
31
32 -- Index tracking which blocks are used by which snapshots.
33 create table snapshot_contents (
34     blockid integer,
35     snapshotid integer
36 );
37 create unique index snapshot_contents_unique
38     on snapshot_contents(blockid, snapshotid);