> I now want to be able to give the option of opening a second database file, 
> with the same table structure - which i believe is acheived using the ATTACH 
> command. However the ids sent to the client still need to be unique, it is my 
> understanding that a SELECT command will treat both databases as one and so 
> return potentially overlapping ids. Is there anyway to craft the SELECT 
> command - or otherwise -  so that i can know where the id came from and do 
> some form of id mangling, keeping in mind i will need to do the same process 
> in reverse to access the information, given the mangled id.


If you attach the second database a join will let you connects rows in
one table with rows in another table. Then a select can return 2
columns, the id from each table. The two id's concatenated will create
a simple unique key that can be used to find rows in either table.

example:
two tables, named 'a' and 'b'
select a.id, b.id
 from a
 inner join b on b.something = a.something

result:
a.id    b.id
23       34

create a single key by using 6 digits (or binary if you understand
that) for each:

000023000034

There's your unique key that can be used to find rows in either or both tables.

Reply via email to