Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-19-2009, 07:06 PM   PM User | #1
conwaypm
New to the CF scene

 
Join Date: Feb 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
conwaypm is an unknown quantity at this point
Shopping Cart

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.
conwaypm is offline   Reply With Quote
Old 02-19-2009, 07:53 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Users who have thanked Fumigator for this post:
conwaypm (02-19-2009)
Old 02-19-2009, 08:13 PM   PM User | #3
conwaypm
New to the CF scene

 
Join Date: Feb 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
conwaypm is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
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.
conwaypm is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:10 AM.


Advertisement
Log in to turn off these ads.