Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flat Text Database Scripts
08-10-2011, 11:25 AM, (This post was last modified: 08-10-2011, 11:43 AM by RichardGv.)
#4
RE: Flat Text Database Scripts
As far as you are going to do anything serious, I see almost no point to reject SQLite:
  • Why are RDBMS created? Well, the first issue it resolves is concurrent access. Think about the scenario when your site has 5 visitors sending a request simultaneously. 4 of them are trying to read your review about a movie, one person is trying to submit a new comment to your reviews. Since when writing to a flat file it has to be locked to avoid data corruption, the file is locked until the new comment is written to the file, so one person's access is causing latencies for 4 persons. When your sites have, let's say, 100 concurrent requests, flat files would be a total disaster.
  • Permissions. Flat files lack the extensive permission control RDBMS offers, important for large projects.
  • It's hard to provide random access to flat files. Well, it is not entirely impossible to do it yourself, yet it adds much complexity.
  • PHP is an interpreted language, which means, well, it's generally slow. An benchmark showed Python is 3 times faster than PHP, and Java/C++ are roughly 100x faster than Python. (Of course, no general comparison can be done.) It is very unlikely that a PHP script parsing a flat text file could be faster than SQLite, written in C.
  • You may have to convert numbers or other kinds of special data back or to their text representation. Performance penalty.
  • As for XML, it's good for extensibility (yeah, where the "X" comes from), yet bad as a database format. It uses tons of unnecessary tags, does not support random access, and cannot store binary data efficiently, even worse than normal flat files. Also, if you use a DOM-tree XML parser, it would put the entire XML file in memory, thus you would probably need to pay 3 additional bucks a month to add more memory to your VPS. soon
  • Since SQLite uses SQL, it requires less code changes later to move your site to a MySQL/PostgreSQL/MsSQL environment once your site grows larger.
  • Writing a database engine yourself would take a lot of time, and certainly SQLite would be more bug-free than yours, so why bother reinventing the wheels? And there are already tons of tools that enables you to view (graphically) and edit SQLite databases.

However, for simple one-user scripts or a PHP engine with no SQLite support, flat files remain a viable choice, and certain scripts indeed support it.
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply


Messages In This Thread
Flat Text Database Scripts - by MyDigitalpoint - 08-09-2011, 12:51 PM
RE: Flat Text Database Scripts - by zZJoennZz - 08-09-2011, 07:09 PM
RE: Flat Text Database Scripts - by RichardGv - 08-10-2011, 11:25 AM
RE: Flat Text Database Scripts - by Zach - 08-10-2011, 12:36 PM
RE: Flat Text Database Scripts - by OhioTom76 - 07-26-2012, 06:57 PM

Forum Jump: