Am 04.03.2012 15:22, schrieb Kit:
2012/3/4 Christoph P.U. Kukulies<k...@kukulies.org>:
CREATE TABLE dir(filename text, md5sum text, size int, content blob,
    PRIMARY KEY(filename,md5sum,size));
Coming back to your suggestion using PRIMARY KEY(filename,md5sum,size), how
would I address this PRIMARY KEY, example:

I'm building a table
CREATE TABLE candidate (?,client TEXT, md5sum TEXT, basename TEXT, size INT,
...some other stuff )
The ? should stand for the - is that FOREIGN KEY? - key in the dir-TABLE
which is formed of filename,md5sum,size.
Christoph
Foreign key is (basename,md5sum,size).

Your example shows that a composite key in this case is possible, but
it is not appropriate. Use simple key md5sum. Make two tables.

Attribute "size" (part of primary key) is redundant.

Kit,

I'm coming back again on your suggestion. Maybe you can elaborate, why
size is redundant and of what I should make two tables?

Let me describe the problem again:

I'm going recursively through a directory tree collection information on all files, that is,

CREATE TABLE instance  (
          path TEXT,
          md5sum TEXT,
          basename TEXT,
          size INT,
          creation_date TEXT,
          last_write_time TEXT,
          );

CREATE TABLE resource (
          size INT,
          name TEXT,
          md5sum TEXT,
          data BLOB,
          primary key(basename,md5sum,size)
        );

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

md5sum = md5sum
size = size
name = name (allowing different names sharing the same resource is another thing - I might do that but do
not want at the moment).

So when I'm now visiting every file I will check whether the file with its contents has already been entered into the
TABLE resource.

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?

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








_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to