X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=schema.sql;h=850e6a9ace316196a494d7a91b77a95f7c21ceb0;hb=b41d7697d060b3675ae160ef8b88c51e642b0c99;hp=8518c4fa7fc2922ae9575b4a50c19a77d3620be6;hpb=da87780779a2f165503d019ee0b59d10e5d31ec8;p=cumulus.git diff --git a/schema.sql b/schema.sql index 8518c4f..850e6a9 100644 --- a/schema.sql +++ b/schema.sql @@ -3,19 +3,53 @@ -- -- The index is stored in an SQLite3 database. This is its schema. --- Index of all blocks which have been stored in a snapshot, by checksum. +-- List of snapshots which have been created. +create table snapshots ( + snapshotid integer primary key, + name text not null, + scheme text, + timestamp real, + intent real +); + +-- List of segments which have been created. +create table segments ( + segmentid integer primary key, + segment text unique not null, + path text, + checksum text, + mtime real, + size integer, + expire_time integer -- snapshotid of latest snapshot when expired +); + +-- Index of all blocks which have been stored, by checksum. create table block_index ( blockid integer primary key, - segment text, - object text, + segmentid integer not null, + object text not null, checksum text, - size integer + size integer, + timestamp real, + expired integer ); create index block_content_index on block_index(checksum); -create index block_name_index on block_index(segment, object); +create unique index block_name_index on block_index(segmentid, object); --- Index tracking which blocks are used by which snapshots. -create table snapshot_contents ( - blockid integer, - snapshot text +-- Summary of segment utilization for each snapshots. +create table segments_used ( + snapshotid integer not null, + segmentid integer not null, + utilization real ); +create unique index segments_used_index + on segments_used(snapshotid, segmentid); + +-- Overall estimate of segment utilization, for all snapshots combined. +create view segment_info as +select segmentid, mtime, size, expire_time, + cast(size * utilization as integer) as used, utilization +from segments join + (select segmentid, max(utilization) as utilization + from segments_used group by segmentid) +using (segmentid);