Am Montag, 3. Oktober 2016, 10:42:02 CEST schrieb Pascal Obry:
> 2016-10-02 16:12 GMT+02:00 Tobias Ellinghaus <m...@houz.org>:
> > darktable master just introduced a long awaited change: splitting the
> > library into two databases, one library.db with image related things and
> > data.db which contains all the globally useful information like styles,
> > presets and tags. Please have a look at the console output for a while
> > and look for any SQL errors and report them!
> 
> I've had a look this morning. There is something that bother me.
> 
> In data.db we have the tags (tagsid -> name) and in library.db we do
> reference the tags (imagid -> tagsid) for each image.
> 
> This means that if we lose data.db we also loose all tags in images
> and it also means that library.db is not self sufficient.
> 
> Am I missing something?
> 
> Maybe all this has already been discussed?

I thought about this a little more and might have come up with a solution. 
Without indices it would look like this:

data.tags:
    id INTEGER PRIMARY KEY AUTOINCREMENT
    name VARCHAR
    -- ... maybe some of the other things but I would like to clean that up

main.used_tags:
    tagid INTEGER PRIMARY KEY AUTOINCREMENT
    name VARCHAR

main.tagged_images:
    imgid INTEGER
    tagid INTEGER
    PRIMARY KEY (imgid, tagid)

Note that the id of data.tags is NOT related to main.used_tags.id! When 
tagging an image the tag is inserted into both data.tags and main.used_tags 
(if not there already) and main.tagged_images gets a line with the tagid from 
main.used_tags.
At startup all tags that are in main.used_tags but not in data.tags are copied 
over to data.
When searching for tags data.tags is used.

The only drawback with this is that there would be an extra JOIN to find all 
images with a given tag when building a collection.

What do you think? It would allow to have your tag list regardless of what 
library is loaded and library.db would be working independent from data.db.

> Regards,

Tobias

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to