From eeffd229bbea36a964487bc7f8b620e4774830e8 Mon Sep 17 00:00:00 2001 From: kris Date: Thu, 4 May 2017 21:25:33 +0100 Subject: [PATCH] Initial schema for disk metadata --- apple2.schema | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 apple2.schema diff --git a/apple2.schema b/apple2.schema new file mode 100644 index 0000000..56a716a --- /dev/null +++ b/apple2.schema @@ -0,0 +1,54 @@ +-- SQLite3 schema for storing metadata about Apple II disk images + +create table Disks ( + -- Fully-qualified file path + path TEXT PRIMARY KEY, + + -- Shorter human-readable name for disk + name TEXT, + + -- SHA1 hash of data + sha1 TEXT NOT NULL, + + - Optional disk contents + data BLOB, + + boot1_sha1 TEXT, + FOREIGN KEY(boot1_sha1) REFERENCES boot1(sha1) +); + +-- Boot1 is T$00S$00 and invoked by the Disk PROM +create table Boot1 ( + -- TODO: should also have a unique id to avoid repeatedly storing the same hash in Boot1Distances + + -- Uniquely identified by sha1 hash of data + sha1 TEXT PRIMARY KEY, + + -- Optional human readable name for boot1 object + name TEXT, + + -- Other notes about this boot1 object + notes TEXT, + + -- 256 bytes of binary object code + data BLOB NOT NULL, + + -- Optional Disassembly of 6502 object code + asm TEXT +); + +-- Levenshtein distance between pairs of boot1 images +create table Boot1Distances ( + -- References boot1.sha1 + source TEXT, + + -- References boot1.sha1 + target TEXT, + + -- Levenshtein distance between binary (base-2) sequences + distance INTEGER, + + FOREIGN KEY(source) REFERENCES boot1(sha1), + FOREIGN KEY(target) REFERENCES boot1(sha1), + PRIMARY KEY (source, target) +); \ No newline at end of file