On Sat, 22 Jun 2002, Amir Hardon wrote: > On Saturday 22 June 2002 14:06, Shlomi Fish wrote: > > On Sat, 22 Jun 2002, Amir Hardon wrote: > > > Hello all, > > > I'm writing a set of CGI programs that generate's a home site according > > > to some data (The idea is to make the creation of a homepage very > > > simple... just enter some texts choose colors and you have your site). > > > > > > I don't know what will be the best way to store this data, my options are > > > using an SQL server, or just storing the data on a file. > > > > > > What should be my considerations? > > > > First of all, a homepage as the web-server is aware of is a set of static > > (or auto-generated) files found under a directory of the machine. I hope > > you know that. > > > Why can't a home page be http://foo.bar/a.cgi?page=myhomepage ? > In this case many homepages are being accessed from the same file... >
I suggest you avoid this scheme. It is possible for a CGI script to serve a virtual directory structure. I.e: http://myhost/myhomepage.cgi/shlomif/humour/... You can see how to do it by looking at the environment variables and tweaking an Apache directive that I forgot its name. This will give the users a better homepage-like feeling and will make search engines happy. > > > > > Now, the questions whether to store in a file or in an SQL database should > > have several considerations: > > > > 1. Do you require processing the entire data for every invocation of one > > of the CGI scripts, or is it possible that the script will only need a > > small subset of the data? > > > > If the latter is the case, then a properly managed database of some sort > > (not necessarily an SQL one) would be a better choice.[1] > > > > 2. How much do you care about security? Working with an SQL database is > > generally more secure than working directly with the filesystem. I don't > > mean that the latter is inherently non-secure, it's just that it requires > > more care to get right. (e.g: '../../../../../etc/passwd') > > > > 3. How much do you care about performance? An SQL database has a lot of > > overhead, and working with a non-SQL one, or directly with data files, > > can be faster by a few good factors. > > > The script requires some of the data each time it is executed > security is always important... and as long as the server keeps running I > don't care about performance but I expect many visits... > If not SQL so what database do you recommend? First of all - you have two approaches: 1. Create a script that manages a static directory structure, that is then served by the web-server. 2. Create a script that serves the homepage on the fly. The first approach is faster. The second approach may be more flexible as you can give the users some flexible server-processed markings. As for choosing between SQL or a non-SQL database: an SQL one gives you a lot of powerful querying logic that you don't have to re-invent on your own. A non-SQL one gives you better performance and possibly fine control over your queries. Of course if you program in a high-level language, an SQL server may still be faster because of the overhead of controlling the search operations. For more information, consult the following Freshmeat Categorical Reviews: http://freshmeat.net/articles/view/305/ http://freshmeat.net/articles/view/307/ Regards, Shlomi Fish > > Regards, > > > > Shlomi Fish > > > > [1] - There's a very illustrative article about why this is the case here: > > > > http://www.joelonsoftware.com/articles/fog0000000319.html > > > > > Thanks, > > > -Amir. > > > > > > ================================================================= > > > To unsubscribe, send mail to [EMAIL PROTECTED] with > > > the word "unsubscribe" in the message body, e.g., run the command > > > echo unsubscribe | mail [EMAIL PROTECTED] > > > > ---------------------------------------------------------------------- > > Shlomi Fish [EMAIL PROTECTED] > > Home Page: http://t2.technion.ac.il/~shlomif/ > > Home E-mail: [EMAIL PROTECTED] > > > > "Let's suppose you have a table with 2^n cups..." > > "Wait a second - is n a natural number?" > > Thanks, > -Amir. > ---------------------------------------------------------------------- Shlomi Fish [EMAIL PROTECTED] Home Page: http://t2.technion.ac.il/~shlomif/ Home E-mail: [EMAIL PROTECTED] "Let's suppose you have a table with 2^n cups..." "Wait a second - is n a natural number?" ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]