I
I
Igor Vasiliev2018-02-20 07:09:07
MySQL
Igor Vasiliev, 2018-02-20 07:09:07

What is better, writing to a file, or writing to a database??

Hello.
-
Need some advice. How best (safer) to store information. I can write information to a file and to a database.
Recording is carried out by php code
Probability of the number of records - 500,000
There are several tabs with countries, each country tab contains the names of banks and payment systems, each payment system (bank) has its own data to fill in.
As a result, you need to form n-tabs of countries, with n-type of payments, which has n-fields to fill.
Framework: country tabs, payment tabs - customizable and changing.
Fillability: different (depending on needs and country), some fields are required.
That is, the structure is flexible and customizable.
-----------------
Perhaps it would be better to store this in the database, but how much would such a table weigh? To clarify, I am aware of storing data as an array for conversion to a json file. What to do if the table is damaged or hacked? Reading a single line by each individual user per second can be anything.
So, if the script forms an array and writes to an individual json file, there will be, let's say, 500,000 unwritten and custom json files that the user or functions will read at the time of the transaction. If the database fails, the data of payment systems will go into decline, and there will be serious problems for recovery. You can make a backup in MySQL (and if not?)
In the case of a json file, which is rewritten by the user (each one, individually), loaded (read), faster than from the database.
Most likely, in a year, the file with payment data will be edited 1-2 times.
What is more reliable, what is safer? 500,000 db records vs 500,000 json files.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander, 2018-02-20
@Isolution666

Of course DBMS. But you can mix files and databases with a document based solution like mongodb. Or use the functionality of working with json in relational databases, for example, JSONb in PostgreSQL.
Pros: ready-made and proven infrastructure solutions. the disadvantages include the fact that you need to be able to "prepare" the chosen solution.

E
Eugene, 2018-02-20
@zolt85

If on simple, then the DBMS is better.
The database can be scaled, replicated, versioned, normally backed up, there is already a differentiation of access to data by means of the DBMS. Based on the data in the database, you can build analytics.

V
Vladimir, 2018-02-20
@djQuery

As practice shows, sooner or later you will come (in the same project) to the need to use a database. And it's good if it's early.

Y
Yerlan Ibraev, 2018-02-20
@mad_nazgul

It seems to me that it is better to go to study, then there will be no strange questions. :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question