What should I use in this case (Apache + PHP)? Database or just a TXT file? My priority #1 is speed.
Operations
Thank you.
+----------+-----+
| Name | Age |
+----------+-----+
| Joshua | 32 |
| Thomas | 21 |
| James | 34 |
| Daniel | 12 |
+----------+-----+
Joshua 32
Thomas 21
James 34
Daniel 12
Yes you can use a . txt file as a database but you should make it a lot easier on yourself in the long run and learn mySQL in a couple of hours so you are doing it more along the lines of industry standards.
The primary advantage of a database vs a text file or an single data file (aka a flat file) is that a database allows you to capture relationships across single data files.
The three main advantages that databases have over other, simpler data storage systems (such as text files and spreadsheets) are access, integrity, and security.
A file with . TXT extension represents a text document that contains plain text in the form of lines. Paragraphs in a text document are recognized by carriage returns and are used for better arrangement of file contents.
For speed and optimized memory usage, I'd say go with a database hands down. Putting an index on the name column alone will probably boost performance in a way never achievable with a text file.
A database has also other advantages like some sanitation (no breaking of delimiters, newlines etc.) and less danger of access conflicts when multiple instances try to read from the table - and different from a file-based approach, writing conflicts are constrained to the record in question only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With