Using a db is a better choice, if not now - for the future. While it will be a chore to migrate, you will be able to extend your system any number of ways. Mailing list for product updates. Boolean searching. Better security. my 2cents. Cameron "Chris Blessing" wrote > > Hey folks- > > I've been assigned the project of creating a shopping cart system for my > company's website. We just wanted to implement basic Amazon-esque features > as well as a coupon system, and at this point I'm done. The way I've > written it, however, is beginning to be challenged by myself in my dreams, > so I need some input. =) > > I wrote this cart system knowing that our servers are not over-loaded and > that our site is not extremely busy, nor is it the nature of the site to get > extremely busy. The backend of it all is composed of a function library I > wrote for adding items, removing items, displaying cart information, etc. I > implemented the whole thing using arrays (2d arrays, specifically) based on > some material I read on 4guysfromrolla.com. While it works beautifully, I > can't help but wonder if the system would be a bit more scalable and perhaps > easier to maintain and add to (later on, if necessary) if it was based on a > database rather than arrays. > > For example, Joe adds an item to his cart. Right now this is an added > element in the main cart array, but it could just as easily be an inserted > row in a database table. Right now, if Joe removes that item, I have to > create a temp array and loop through the original cart array, copying every > item except the deleted one into that array, then destroying the old array. > With a db system, I could just delete it and be done with it. > > It would also be a lot easier to implement the coupon system, since I have > to hit the database server anyhow to get the coupon's information. > > My question is then, should I stick with arrays or move to the db? The db > server is a separate machine, not terribly overloaded, and the system specs > are great (quad-proc, 4gb ram, etc.). I just don't know if there's any > performance benefit to be gained from this though, since the arrays ARE > local and ARE residing in memory constantly, therefore access to them is > very fast, whereas the db server is across a network. > > Any thoughts/input are much appreciated! > > Chris Blessing > webguy at mail.rit.edu > http://www.330i.net > > -- > For unsubscribe and other options, including > the Tip Harvester and archive of thelist go to: > http://lists.evolt.org Workers of the Web, evolt !