[Digikam-users] Database inconsistencies

Jean-François Rabasse jean-francois.rabasse at wanadoo.fr
Wed Dec 12 13:00:52 GMT 2012



On Tue, 11 Dec 2012, Matthieu Pupat wrote:

> Hello,
>
> I found what I suspect to be a few inconsistencies in my digikam database
> and would like to know if there are any tools to clean them up and if it is
> safe to remove those orphan entries listed below:
> ...

Hello,

My general comment is that it's never « safe » to correct by hand databases
inconsistencies, because a database should never have inconsistencies.
If yes, there's a big problem somewhere, either an application inconsistent
schema or a database driver problem. In both cases, you can't guess in a 
reliable way what final state you will get after hand tweaking and what
could be the future behaviour.

But you don't say what kind of DB uses your Digikam. MySQL or SQLite3 ?

SQLite3 has integrity constraints problems, depending on the implementation.
As you seem used to SQL, try on a new test DB some simple tests, e.g.
create table images (
     iid integer primary key);

create table comments (
     cid integer references images(iid) on delete cascade);

Now populate your images table with a couple of values, 1, 2, 3
Try to create a comment with cid 4, it should be forbidden.
With my version of SQLite3 it works :-(

Try to create a comment with cid 2, then delete the image with iid 2.
The comment should be cascade deleted. With my SQLite3 it isn't :-(

Same weird behaviours when using triggers.

If you have that kind of behaviour, it's not a Digikam problem at all.
You should forget the idea of having a stable and consistent database.
The best way is, from time to time, to have your metadata in images, then
destroy the Digikam DB, then restart from scratch and let DK browse your
collections and recreate all stuff.



Regards,
Jean-François


More information about the Digikam-users mailing list