...

View Full Version : Shopping Cart



conwaypm
02-19-2009, 08:06 PM
Hi all. I'm coding an online shop for a project. I'm using AJAX extensively on the website and serving it with java servlets. On the back-end is an sql database.

I'm wondering what is the best way (if I should at all..) to represent the shopping cart in the database. The entities I currently have are..

Product [product id, artist, title, description, cost]
User [userid, username, userpassword]

A many-to-many relationship exists between the Product and ShoppingCart and I'm unsure how to construct an intermediate table between the two. I was thinking to use a CartItem entity that can hold a productID, quantity and a userID. That way I can have my ShoppingCart entity have two attributes (cartID and userID).

Sorry if I havn't explained that very well but hopefully someone can tell me if the above solution is workable.

Fumigator
02-19-2009, 08:53 PM
For doing a simple shopping cart I would probably do something similar to what you describe; shopping cart table stores user id, shipping and payment info, cart item table stores product id and quantity (and perhaps product price, depending on the nature of the product and how fluid the pricing structure is). I wouldn't bother storing user id in the cart item table, as it is already stored in the shopping cart table.

conwaypm
02-19-2009, 09:13 PM
For doing a simple shopping cart I would probably do something similar to what you describe; shopping cart table stores user id, shipping and payment info, cart item table stores product id and quantity (and perhaps product price, depending on the nature of the product and how fluid the pricing structure is). I wouldn't bother storing user id in the cart item table, as it is already stored in the shopping cart table.

Thanks very much for that. It's really helped me clear things up in my head. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum