data storage

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi All,
    I want to be able to store data as part of my website. I'm assuming that
I''ll need to use PHP scripts to provide this functionality, but what would
the best aproach be to storing data?. I could use a database of some sort
(maybe MySQL?), but I'm wondering whether there are any other aproaches to
data storage that would be less elaborate than a full database.

Any ideas?.


Re: data storage

Dave Moore wrote:

Quoted text here. Click to load it

Hi Dave,

Well, you can always use files to store data.
But you should wonder if the initial ease of coding is not backfiring later.
(I think it will)

If you use files to store data (often called: flatfile approach), you will
face a LOT of extra headages later on in the project, like:
- bad performance

- you have to prepare your files against concurent writes by different
request/commands from clients.
Use filelocking to prevent this. (= extra work)
If you do not it is just a matter of time before your files become corrupt.

- If the data you store is even a little bit complex, you will soon face the
fact that you have to open many files, scan them, do a lot of processing.
This is EXCACTLY where SQL makes things easier for you.

If you have no experience using databases, this might be a little
intimidating at first glance.
But take it from a guy who did actually make dynamic websites using flat
files in Perl: it is ABSOLUTELY worth the time/study investment.
Go database.

Of course I do not know your actual requirements, but studying databases is
most probably worth your while.

Have a look at for some great tutorials.

As for your choice of database: Go mySQL or Postgresql.
I think both are under the GPL licence. (= Free as in Freedom :-)
I prefer Postgresql because it is a robust, featurerich opensource database.
But MySQL should do most jobs just as fine (and a little bit faster. :-)

Hope this helps.

Erwin Moller

Re: data storage

Dave Moore wrote:

Quoted text here. Click to load it

How much data?  What kind of data?  Do you mean pictures and text documents
or things like sales orders and employee records?

Generally, if you are going to store business data, you will sooner or later
master a database, so you can start now or start later.  Many try to gloss
over this fact and it limits what they can get done.

If it is not business data, it gets more gray and you would have to provide
more details.

Kenneth Downs
Secure Data Software, Inc.

Re: data storage

Dave Moore contained the following:

Quoted text here. Click to load it

Database or files.  Take your pick.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: data storage

Following on from Dave Moore's message. . .
Quoted text here. Click to load it
MySQL is a doddle.  myAdmin is a convenient management tool.
Documentation for MySQL is excellent.  You'll find it handy anyway.  Now
is your opportunity to emerge from the primeval swamp as it were.

Large user supplied data files might be better in a file system -
uploading files isn't difficult.  Downloading files is only half a dozen
lines of code....
....but you'll need some database to manage the files.

Or you could try carving the information as intricate designs on
potatoes, chips and crisps.  A taterbase.

PETER FOX Not the same since the poster business went to the wall
2 Tees Close, Witham, Essex.
Gravity beer in Essex  <

Re: data storage

Hi Erwin,
    Thanks for the pointers. I am slightly familiar with SQL 'INSERT',
'SELECT' etc, so this is not too scary. However, can you recommend a
webspace hoster that will accept server side PHP and MySQL databases to be
run?. Also, how would you suggest that I approach developing the site? -
should I develop using a webserver (like Apache) on my desktop locally and
then keep my fingers crossed that it will port OK to a hoster's webserver?.


"Erwin Moller"
Quoted text here. Click to load it

Re: data storage

Dave Moore wrote:
Quoted text here. Click to load it

I'd expect it to be more difficult to find hosts that *don't* support the
PHP and MySQL combination. Plenty of inexpensive hosts out there. I use but there are hundreds of others out there. Visit for background on many web hosts.

Yes, do your development locally and then post it when it's ready... or have
two hosted accounts that you use so there is a development and a production
environment. It's worth it.


Re: data storage

Virgil Green wrote:

Quoted text here. Click to load it

Yes, Virgil is completely right: Every ISP that is worth anything should
offer it.
Only exception are those pesky W$-only providers, they tend to stick ACCESS
and SQL-server.
If you are lucky they offer MySQL too.

But please try to find an provider that offers:
- GNU/Linux OS.
- Apache (1.3 or higher)
- PHP (at least 4.3, but preferably PHP5)
- MySQL or Postgresql

Relevant might be the LAMP shortcut:

But I don't like that name LAMP, because it doesn't pay credit to the
GNU-part in Linux, which makes up over 95% of what many people call Linux.
GNU/Linux is a better name.

I live in the Netherlands, Europe.
The best deal over here is XS4ALL. They run FreeBSD, and are very good
technically. (Maybe they run GNU/Linux too, not sure)

Quoted text here. Click to load it

Dave, Virgil is giving very good advise.
If possible try to do that.
You are doing yourself a huge favor. :-)

Good luck.

Erwin Moller

Re: data storage

SqlLite is a thing  you need|~maybe

Re: data storage

Quoted text here. Click to load it

Very deep question, database is easier for most things, particularly updates
and queries. mysql is more popular, which is why I use it. I perfer postgresql
though. You don't have file permission issues with mysql. (Just access issues)

DBM's are some-what less elaborate.

There are a few dbm implementations, these are files but you get a key -> value
type of interface. Useful for high speed access, terrible if you need to span
hosts. Shouldn't be a problem to serialize an object and store to a DBM, this
would give you a "key => $object_or_array" type of functionality. It would
be terrible if you needed to lookup data based on something besides a single
primary key. (You'd have multiple "alternate index" DBM's to maintain on each

Flat files are often good for file uploads.

I tend to use a combination of database + files, for the different data.

I'd probably go with an SQL database, it'll make your life easier in the long
run and probably make your web site more stable.

--                     Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions

Re: data storage

Quoted text here. Click to load it

If your host runs PHP 5, you can use SQLite.

Site Timeline