View Full Version : A good format for storing small databases (>100 records) in text files?

07-30-2003, 01:39 AM
I'm looking to use a text file to store a small database (>100 entries most likely) for a calendar. It would be web-editable through a PHP script. I have access to a MySQL database but do not wish to take the time to learn SQL and would rather store all information in a text file (I don't want to be roped in to having to host with a MySQL provider).

My current idea would be a database with one record per event, something with these fields:

date(DD.MM.YYYY format, easily splittable by the periods)
event_author (for keeping track of who adds each new event)

I was looking into a tab-delimited-type file, but as I would most likely use the PHP functions file() and then a regex split by tab, this wouldn't work: the event_summary field could easily have new paragraphs in it, which would involve some sort of replacement character to keep line endings and entry records correct.

Does anyone have any suggestions on a good file format? Or should I just replace new paragraphs with some sort of text string like "\p\" and stick with tab-delimited files? Thanks!

Jeff Walden

07-30-2003, 03:55 AM
If your going to be having paragraphs, it seems to be easier and much more efficent to use MySQL. Especially if you are going to be having more than a 100 entries. If you are concerned about learning SQL, don't, it is incredibly easy. Plus PHP and MySQL work easily together.

Check out: http://www.w3schools.com/sql/

If your using PHP, most hosts will have MySQL support.

07-30-2003, 03:45 PM
You know, the more I think about it, the more I think I will use MySQL. I should have remembered being forced to host with an SQL provider (often at extra cost) won't be a problem if I have to switch hosting services - the new PHP (5.0.0 Beta) will have a database system (SQLite) built-in, so I won't need to worry about having to host with someone with a DB program, I'll just need one running a newer version of PHP (or I can ask if they could install the newer version).

Thanks for the help!


08-03-2003, 06:57 PM
why don't you store it without database , into XML files

<?xml version="1.0" encoding="ISO-8859-1"?>
<event id="1">
<date />
<name />
<summary />
<location />
<author />

08-03-2003, 07:02 PM
I did consider XML, but looking through the manual pages for it in PHP, it looked a little harder to do. Or at least to understand - the MySQL stuff, after a quick SQL tutorial, is pretty straightforward, I think.

Anyways, it's moot now, as I'm in the middle of coding using the MySQL database I have access to. I've run into the occasional problem, but they've been nothing I can't work my way through eventually.