Giulio Prisco Giulio Prisco - 19 days ago 5
Android Question

Multiple tables or multiple dbs in Android app?

I am writing an Android storytelling app to create and edit stories with texts, pictures, sounds etc. So far I have one story, one database, one table, and everything works fine. Now I will move to multiple stories and I am thinking of whether to keep a single database with one table per story, or having multiple databases, or a combination of the two (like 10 tables per database). I will need to up/download stories to/from a storage service.

Answer

I am not sure, but I think the main problem is your basic database scheme. I can't imagine that the table you have created for one story can't be normalized into separate tables.

So create a table for a story containing the story title, for example. Than a table for texts and sounds and everything else you need. Each of these tables will have a foreign key so that they can be referenced to the story they belong to.

That should also solve the problem of thinking about separate databases or tables for a story.

Also keep in mind that you have to deal with database scheme changes on every database when you decide to have a single database for each story. Might be a mess and complicated when you have to update 10 different databases just because you added one column to the table...

Comments