When saving text in a website, is it better to save it in a .txt file or in a MySQL database?
-
Also, what are the disadvantages of each, and which data type (VARCHAR, TEXT...) should I use to save it in a MySQL database?
-
Answer:
Better is a litte subjective here. It really depends on what you're wanting to do with the text after you've saved it. If you're going to want to index it, search it, and re-display it on the site then you should save it in the database. If you want to download it to your computer, or make it shareable at a filesystem level then making text files would be better. As to the data type, varchar is generally faster with less overhead (it's stored with the table, whereas text and blob are stored outside of the table), but you do have a tradeoff as more data is added to a varchar column it gets slower, and at that point text or blob would be faster.... The problem is which one is best is dependent on the hardware and the data you're storing.
Chris Pickett at Quora Visit the source
Other answers
If you need to sort, search or filter your data, you are certainly better off with storing your data in a database. Sorting, searching or filtering records is what databases are made for! I have seen some web site management systems or mail servers which store data as files not fields, they may be easy to move from btw servers or run free text search on, but that's among the few advantages. Nearly every data system is based on records, fields, keys and relations between keys, and that's actually what a database is.
Harald Groven
Chris Pickett's answer covers the most important point. I would mention specifically that if extensive text searching is involved, you may want to avoid naive options in MySQL and look into Sphinx, Lucene, etc, for fast, flexible and scalable searching.
Toby Thain
Related Q & A:
- How do I convert a PDF file to PDF/A in Delphi?Best solution by softwarerecs.stackexchange.com
- How to delete a line from a .txt file in node.js?Best solution by c-sharpcorner.com
- Is there a website where i can either download or play a program that will let me build a building, like?Best solution by Yahoo! Answers
- How is .txt file different from a .dat file in C?Best solution by mycplus.com
- How to put a video file on to a disc?Best solution by wikihow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.