-2

In my application, the customer will be given a set of 5 choice based questions. Based on the answers, he will get an offer. The answer choices and offers are mapped in the following way.

[1,3,2,5,4] - Offer No.5,

[1,1,1,2,1] - Offer No.2

Totally some 30 mappings.

This is where i need a clarity. Should i store it in the application db or in a file ? Which is the best approach and why ?

Partheey
  • 3
  • 5
  • Is it static data? Does it need to be edited? Does it need to be edited *programmatically*? How often does it need to be edited? Is it easier to write it in something simple to edit like YAML/JSON? Is that ease worth any tradeoffs vs. a database? Does the data need to be *queried*? How complex are the queries? Is it easier to write the queries in SQL or read a static file and apply some code logic? – In the end ***you*** need to decide! – deceze Feb 08 '16 at 11:21

2 Answers2

1

Proper DB is almost always a better choice for multiple reasons:

  1. It solves issues that at the moment you are not even aware they exist but which you will face sooner or later (e.g. consistency, efficiency, atomicity, etc.).
  2. It allows easier scaling of app servers (if we are talking about dedicated db servers).
  3. It is easier to manage (e.g. indexes, CRUD queries, etc.). Don't reinvent the wheel, use fruits of others hard work.
  4. Can be easily extended at relatively low cost.

But if you don't necessarly think you will ever need multiple machines then sqlite is still a better choice then manual file handling.

freakish
  • 54,167
  • 9
  • 132
  • 169
0

The file system needs parsing numbers, dates (records in DB's) and so on ... You should be aware that the contents of a txt file won't be indexed. But in DB, data can be indexed and you can query the database to get the results. So it's useful for management purposes. Another one is relational model, So data doesn't need to repeated over and over (which we know as redundancy in DBMS's)

So after all you should know that file System may be useful in some cases, But not all cases.

inverted_index
  • 2,329
  • 21
  • 40