[thelist] Backend of a shopping cart system...

Chris Blessing webguy at mail.rit.edu
Fri Apr 5 08:15:01 CST 2002


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




More information about the thelist mailing list