2012/3/9 Christoph P.U. Kukulies <k...@kukulies.org>:
CREATE TABLE instance  (
         path TEXT,
         basename TEXT,
         size INT,
         md5sum TEXT,
         creation_date TEXT,
         last_write_time TEXT,
         FOREIGN KEY (md5sum) REFERENCES resource (md5sum)
         );

CREATE TABLE resource (
         md5sum TEXT,
         data BLOB,
         primary key(md5sum)
       );

> What makes the contents of two files equal (so that their contents can be
> represented by the same resource) ?

md5sum = md5sum

> My problem: what do I have to change in TABLE instance so that I can use it
> to determine whether the key is already
> in the resource TABLE?

- Make new md5sum from new data
INSERT OR IGNORE INTO resource ...
INSERT OR REPLACE INTO instance ...

> Would that be a FOREIGN KEY? And how would I do that in syntax?
> If I need FOREIGN KEY, would I have to enable that in SQLite somehow (at
> compile time)?
> Thanks,
> Christoph

PRAGMA foreign_keys = ON;

in runtime. But you don't need foreign keys support in this case. You
may use it for garbage collection.
-- 
Kit
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to