0

I have this scenario: one database in the app and many database that are downloaded from different devices and saved in the same database folder:

mydatabase.db           // database of app
device1_mydatabase.db   // database from device 1
device2_mydatabase.db    // database from device 2
device3_mydatabase.db    // database from device 3
....
... 

All databases have the same structure , because are the same app in different devices. I have one query that obtain the total production from the mydatabase.db. I would like to obtain a total query from all databases.

1) is better to create a new database copy and insert all data from the single database and then query the total or there are different better approach?

1 Answer 1

1

This may be a matter of opinion, but I think it is better to load the data into a single database. This gives more control for the application. Here are four reasons that come to mind:

  1. You can optimize the database for the queries that you want to run (say by changing indexes or restructuring tables).
  2. You can incrementally load the tables into the master database as they become available.
  3. Adding another device does not require changing the final queries that are run (just the loading code).
  4. If you change the underlying database structure, then you will have an issue where the databases are not identical. Having a layer in-between isolates the final queries from the original databases.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.