Jan schrieb:
> thx Ibrahim. Give me some time to digest yours and other suggestions.
>
> But it seems I will end up with a adjunct list PLUS something. Of course 
> you are right: I need to store many other information for each animal. I 
> definitely need to use a database (sqlite of course). It will be used 
> for storing breeding informations for agriculture livestock (no lab mice 
> or so similar). So the generation cycle is not too short.
>
> Bye
> Jan
>
>   

A summarized solution for your problem would be :

A) Database entries :

CREATE TABLE tanimals (
    animal_array_index INTEGER PRIMARY KEY,
    animal_id INTEGER,
    ... further fields if needed ...
) ;

CREATE UNIQUE INDEX idx_tanimals_animal_id ON tanimals (animal_id) ;

B) Index File Structure :

struct TSANCESTORINFO {
    int animal_id ;
    int arridx_father ;
    int arridx_mother ;
} ;

C) Comments :

This is the fastest way to implement your application using sqlite and a 
external index file. Even if you use other algorithms you'll only gain 
minimalistic speed while you resolve animal_id >> array_index. The main 
iteration is made with the fastest possible speed. Insteed of iterating 
through indexpages you directly access the parents of each animal in 
your array.

When you have resolved the animal_id >> array index association you find 
the real array indexes of the parents in the indexfile. After you have 
the needed animal_id's of the ancestors you can get all recordsets of 
them with a single select statement

SELECT * from tanimals where animal_id IN ( ... list of found 
animal_id's of the ancestors ...) ;


hope this was useful have fun ;)

Ibrahim

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

Reply via email to