Search code examples
databasejava-ee-6flat-filecdr

Where should transaction records go? Flat file or Database


I'm developing a Java Enterprise Application which needs to write transaction records either to flat files or directly to a relational database. Transaction records are records which show when the transaction starts, ends, transaction status (success/failure) and also data unique to this transaction.

These transaction records will then be used to generate reports. The reports generating tool reads data from a database and generates them.

If flat file is used, records will be eventually loaded into database for reports generating. This adds an extra step.

If database is used, there will be no flat file. My concern is that if database is down, some records will be missing. Thus this approach is not as secure as the flat file one.

So, I cannot decide. Maybe there are other things I didn't consider? What's your view?

Thanks in advance.


Solution

  • If you DO use a flat file, you'll need to worry about locking and flushing and all of that garbage. Furthermore, it can only live in one place which makes it a pain if you ever want the app to scale. Go with the database unless downtime is a REALLY big concern.