开发者

Need advice on adding items to Shopping Cart

I'm about to implement a basic shopping cart. I've already done this before, but am looking for a better way.

Basically, the way I had the Table setup before was like this:

MyCart table:

UserId     ProductID     Quantity     TotalPrice
06         PID08         1            499.00
06         PID06         2            200.00
06         PID04         1            499.00
06         PID01         1            499.00
06         PID09         1            499.00
02         PID25         1            499.00

As you can see, there are only 2 customers who have added items into their Cart. There are five items in 06's shopping cart, and 1 item开发者_如何学JAVA in 02's shopping cart.

I'm thinking it would be better to put them into an array, instead of just adding and adding and adding. But, what about a list? Can you add a list to a DB Table? How would you add items to a "Cart"?


This is almost exactly how I would implement it, except that I tend to use GUIDs as keys.

However, you shouldn't store the price in that table; it can easily be calculated by multiplying the product price by the quantity.
If you allow custom per-user pricing, storing the price here might make sense, although it would still be better to store the information that led to the price.


for a shopping cart, since there would be quite a bit of activity, I would use a NoSQL option, like MongoDB where you can save your C# objects http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜