Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Shopping Cart

  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • Users who have thanked Fumigator for this post:

    conwaypm (02-19-2009)

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •