Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 508393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:54:10+00:00 2026-05-13T06:54:10+00:00

I am currently creating a custom e-commerce site (in php, but that’s not really

  • 0

I am currently creating a custom e-commerce site (in php, but that’s not really relevant for this question).

I have just got to creating the shopping basket, and cannot decide between the following 2 options:

option 1:
Basket table:

  • id
  • user
  • items

In this option, I would have one row per user, with all of the items and quantities stored in the items field.

This format is already used in the cookie based basket for non-logged in users, so parsing of the items field is no problem.

option 2:
Basket_items table:

  • id
  • user
  • item
  • quantity

In this option, I would have one row per item in the basket.

option 3:
suggest a better idea.

conclusion

Both of these options are equally easy for me to implement, so the question comes down which would be more efficient/convenient for updating the basket.

Thank you for any answers, Nico

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:54:10+00:00Added an answer on May 13, 2026 at 6:54 am

    Option 2 is the way to go. Storing all items and quantities in items field (option 1) means you are going against the relational nature of MySQL. You’ll have to define a format and parse it with option 1, additional code you don’t have write with option 2. Also, with Option 2, you’ll be able to do other things easier down the line, like calculate totals, shipping amounts, etc, as well as reporting on item quanities sold (just a simple query).

    Of course, if I was writing this, I’d also ask myself if there is a library available to do this – why reinvent such common a functionality as shopping cart. I am not from PHP world, so I don’t know what the options are, but I am sure there must be something you can reuse. So ultimately, I’d encourage you to choose option 3 – don’t implement it yourself if you an avoid it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 265k
  • Answers 265k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer foobar._meta.verbose_name May 13, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer The OID part of the MAC address you give (01:00:0C)… May 13, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer Look for "HID devices" in the xcode documentation. May 13, 2026 at 12:25 pm

Related Questions

I am currently creating a set of custom media types for a RESTful api
I am currently trying to implement a Custom Configuration Section in a project I
I am creating a custom .net hardware framework that will be used by other
I have been struggling with this for a while and could really use some
I'm tasked with trying creating a site which will create custom HTML templates. The

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.