Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to use SQLite as file format for my app, a reporting program. Below is an idea of the kind of schema I'll use (just the first few tables). There will be one report per file and all tables are children of that. So far so good.

Schema

But I want to be able to merge files, eg. to store 100 reports in one file. I've read that with a little effort, I can use GUIDs in SQLite to avoid dealing with key conflicts when merging databases. Sounds good, but I need a GUID for every record in every table right? That's a lot of GUIDs for my statistics table which might be large!

I then read about multi-column primary keys. Is there any way I can create just one GUID for a report, and have every child of the report incorporate that GUID into its key to make every record's key unique? Is there a better overall approach?

share|improve this question
    
Can you explain in more details what you mean with "to store 100 reports in one file." ? –  ypercube Jan 20 at 17:41

1 Answer 1

It is not possible to have 'hidden' columns.

When you are using GUIDs to avoid merge conflicts, you must use GUID keys in every table that contains data to be merged. And when you already have a GUID, it does not make sense to add another column to the primary key.

If you do not want to use GUIDs, just deal with the conflicts, i.e., instead of blindly copying the records, map all old IDs to new ID values.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.