View Full Version : Is a db really necessary here?
Nocturn
September 14th, 2003, 07:13 AM
Say I have a simple shopping page, with a pic of a product, link to it's description page, and buy button. I also want to have a page where people could easily add a product for this page, along with a pic for it, and a description. This page would then take the submitted info and add the new product to the products page.
A db wouldn't really be necessary here right? Or would it depend on how many products you have? For example I have 50 products, 10 per page. Would it be possible with php to just add a new product to "the end" of the current products, without having to make a db connection everytime someone requests a product listing? Or, if a db would be better to use, would it be possible to just generate the page once from the db, and then for subsequent requests just serve up the already made page?
Jubba
September 14th, 2003, 09:18 AM
a database would make it easier. What is your reason for not wanting to use a database? There may be other alternatives..
tWo48
September 14th, 2003, 01:15 PM
What I think Jubba is trying to say, is that a database would only hurt your problem. I think he has bean incorrectly lead to think that there are other alternatives, when db really is necessary to help your HTML Body Language, while flash is running on a 435 Pentium, you will need to have atleast a 324 to stand by the problem.
Nocturn
September 14th, 2003, 01:26 PM
The reason would just be performance, I see that almost everytime someone talks about using php for their site, it's coupled with a db, and I don't really understand why that assumption is made.
But in this case I guess using a db would be easier, or perhaps just keep the data as xml files? But then perhaps sorting the data would be harder to do then with a simple sql query...Lots of questions :) What are the alternatives?
If I do use a db, is it possible with php to just generate that page once, and not everytime a new visitor loads the page? I understand you can do this with asp.net?
abzoid
September 14th, 2003, 02:04 PM
You see PHP and ASP use associated with databases in mosts cases, because some sort of server side language is a requirement in order to use a database. I agree, that it isn't always necessary, but in the scenario you describe I think it would make managing the data much easier. I do quite alot of database work, and I really don't see a significant performance issue relative to non-database sites.
Now for the last question, yes it is possible to have the administrative portion of the site use PHP or ASP to generate static web pages instead of using it to create dynamic content pages. However, this is a major undertaking, hours and hours of work for an experienced programmer, with relatively little gain for all that effort.
and just for tWo48 :trout:
Digitalosophy
September 14th, 2003, 03:27 PM
a db would probably make your life a bit easier here, especially when they want to add more products.
two48 :
1. what the hell are you talking about
2. why is "Flash" and "pentium" in your post when this thread has nothing to do with either
3. what is that pic supposed to mean
4. are you feeling okay?
Nocturn
September 14th, 2003, 03:29 PM
Thanks a lot for your input abzoid :) I see now for what I have in mind going the db route would be the easiest.
thanks also two48, it's crystal clear :bu:
Jubba
September 14th, 2003, 08:24 PM
1. two48: What the hell are you talking about?
2. If you are only storing small amounts of data that doesn't need to be protected, then you could use text files to store the information, but I don't recommend that. You should use a database. Why would you want to create one static page? What is the difference if you create one static HTML page or one dynamic PHP page?
ahmed
September 14th, 2003, 08:30 PM
Originally posted by tWo48
while flash is running on a 435 Pentium, you will need to have atleast a 324 to stand by the problem. you're mistaken.. you need 248 to stand by the problem!
Nocturn
September 14th, 2003, 08:41 PM
Originally posted by Jubba
Why would you want to create one static page? What is the difference if you create one static HTML page or one dynamic PHP page?
Well, so you don't need to create a db connection, gather data, arrange data, generate the page every time someone visits the page. I thought it would take some load off the server, specially if you get lots of visitors. But apparently this is not the case, or at least the difference is small?
Jubba
September 14th, 2003, 08:44 PM
no. You'd still be loading the same amount of information. The strain on the server is minimal. Thats why server-side languages are so powerful. It allows the creator to make one page and load everything to that page and have the server write the informaiton for the client-side user. I suggest PHP and a database (SQL) for whatever your project is...
abzoid
September 15th, 2003, 07:51 PM
One additional advantage of using a database, and probably the most compelling, is the relative ease of implementing a search.
atomgiant
September 16th, 2003, 10:10 AM
Here are some additional considerations:
1) One alternative would be to actually generate the HTML pages for the products (which someone mentioned a similar approach). Then another php script could be written to link to these static HTML pages. The problem with this is that the pages would be difficult if not impossible to update or change without extensive parsing.
2) There is a free solution to your question about caching pages (i.e. - not regenerating them on every request). It is a templating engine called Smarty (http://smarty.php.net). Smarty allows you to specify the frequency to refresh certain pages. It also keeps your presentation layer separate from your business / decision making layer.
You may also want to check out PEAR for other useful utilities such as Database abstraction and access and such (http://pear.php.net).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.