views:

14

answers:

2

I am extending an e-voting application with a database. Consider multiple concurrent ballots. For each ballot, several configuration options are stored, and also the votes.

The configuration tables are obviously very small, in the presence of a reasonable amount of concurrent ballots, but the votes table can grow to be extremely large.

My question is this: is it better to have the DB concern only one ballot, and have each ballot create a new instance of the whole DB, or to have a ballot_id foreign key in most tables, and store the data for all ballots in the same DB?

My question mainly concerns performance, especially of insertions in the votes table, once it has grown to be huge.

A: 

If:

  • the ballots once closed effectively become read-only, and
  • are also self-contained and unrelated to other ballots,

Then yes, it would seem to make sense to separate them for performance reasons.

Are any tables shared across all ballots? (eg. app-wide configuration) That information would then need to sit in it's own DB.

Will
Yes there are some ballot-independent information, and they would naturally have to reside in a dedicated database. Well, I suppose it's obvious that there will be a preformance benefit. The point is, at which order of magnitude will a performance difference be noticeable. If it's in the billions of entries, then it doesn't matter much.
FrontierPsycho
+1  A: 

My rule of thumb -- keep it in the same DB and use partitioning to manage tables. Using partitioning, you can move "old ballot data" to separate drives and have new data "stream into" latest partitions only. For all the practical purposes, current queries access only a fraction of total table size most of the time.

This way you can still use reporting over the whole table (all ballots) without having to joggle between different databases.

Damir Sudarevic
Thank you, this is the answer I was looking for.
FrontierPsycho