Search code examples
phpmysqldatabasetext-database

Product Analytical data in TXT files (using YAML)


I am currently developing an ecommerce software using PHP/MySQL for a big company. There are two options for me to get some specificed data:

  • DB (for getting huge data, such as PRODUCTS, CATEGORIES, ORDERS, etc.)
  • TXT (using YAML -for getting analytical data and some options)

For instance, when a user go to product details page I need to get those TXT files:

  • Product summary file (product_hit, quantity_sold, etc.) -approximately max. 90KB
  • Langauge and Settings file (such as company_name, translations for template) -approximately max. 300KB
  • May be one more file (I don't know right know) -assume that 100KB.

I want to use this way, because data is easily readable by human and portable between programming languages. In addition, if I use DB, I need to connect a couple of tables. But these files GET THEM TOGETHER.

My txt file looks like (YAML):

 product_id: 1281
 quantity_sold: 12 #item(s)
 hit: 1105
 hit_avarage: 92 #quantity_sold/hit
 vote: 2
 ...

But, still I am not sure about speed and performance. Using TXT files are good idea? Should I really use this way instead of DB?


Solution

  • As you can't partially include and parse a YAML file, you'll have to parse the file as a whole, which means that you'll have an incredible performance hit. You can compare this to selecting all rows from a database and then looping over them to find the one that you're looking for, instead of just typing a WHERE condition. So yes, a database is much faster to accomplish what you ask.

    Please do take a look at Document Based Databases though, you don't necessarily have to use a relational database. In fact, when looking at the example of the YAML file, I think using a "no SQL" database would be a better alternative.

    Cheers.