Strategy on implementing a Shopping Cart with PHP and MySQL












0














I am trying to implement and API . In this API the user has the classic shopping cart. I want to have this shopping cart stored for each user, so when for example he exits/logout from the application , the shopping cart is saved , and thus restored when he login again.



My current implementation is a table with User ID's as a column , and then the columns that have to do with what the shopping cart contains. But I think that this implementation is not good , because when a lot of users are in the platform , then a big search must happen to the table in order to obtain the correct shopping cart for the user, and it will be slow.



An other idea that I have is to make a table dynamic for each user with just one row (with many columns) that will be created for this only user only, in a way that each user will have this dynamically created table and will have quick access to it .



Questions:

1) Can I implement this idea in MySQL

2) Can you suggest a better strategy ?



Thanks for your time.










share|improve this question



























    0














    I am trying to implement and API . In this API the user has the classic shopping cart. I want to have this shopping cart stored for each user, so when for example he exits/logout from the application , the shopping cart is saved , and thus restored when he login again.



    My current implementation is a table with User ID's as a column , and then the columns that have to do with what the shopping cart contains. But I think that this implementation is not good , because when a lot of users are in the platform , then a big search must happen to the table in order to obtain the correct shopping cart for the user, and it will be slow.



    An other idea that I have is to make a table dynamic for each user with just one row (with many columns) that will be created for this only user only, in a way that each user will have this dynamically created table and will have quick access to it .



    Questions:

    1) Can I implement this idea in MySQL

    2) Can you suggest a better strategy ?



    Thanks for your time.










    share|improve this question

























      0












      0








      0







      I am trying to implement and API . In this API the user has the classic shopping cart. I want to have this shopping cart stored for each user, so when for example he exits/logout from the application , the shopping cart is saved , and thus restored when he login again.



      My current implementation is a table with User ID's as a column , and then the columns that have to do with what the shopping cart contains. But I think that this implementation is not good , because when a lot of users are in the platform , then a big search must happen to the table in order to obtain the correct shopping cart for the user, and it will be slow.



      An other idea that I have is to make a table dynamic for each user with just one row (with many columns) that will be created for this only user only, in a way that each user will have this dynamically created table and will have quick access to it .



      Questions:

      1) Can I implement this idea in MySQL

      2) Can you suggest a better strategy ?



      Thanks for your time.










      share|improve this question













      I am trying to implement and API . In this API the user has the classic shopping cart. I want to have this shopping cart stored for each user, so when for example he exits/logout from the application , the shopping cart is saved , and thus restored when he login again.



      My current implementation is a table with User ID's as a column , and then the columns that have to do with what the shopping cart contains. But I think that this implementation is not good , because when a lot of users are in the platform , then a big search must happen to the table in order to obtain the correct shopping cart for the user, and it will be slow.



      An other idea that I have is to make a table dynamic for each user with just one row (with many columns) that will be created for this only user only, in a way that each user will have this dynamically created table and will have quick access to it .



      Questions:

      1) Can I implement this idea in MySQL

      2) Can you suggest a better strategy ?



      Thanks for your time.







      php mysql sql database






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 9:25









      user7337722user7337722

      72




      72
























          1 Answer
          1






          active

          oldest

          votes


















          0














          i have not worked on large e-com websites but i have implemented cart system with MySQL for many times, your approach is good if you want to do some machine learning with cart data.



          i use to delete data after some time interval (a week, a month) days if user has not checkout using cronjob.



          Or



          Send email to the user for checkout, if user done the same then okay else delete the data.



          Note:- This is just a suggestion.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408856%2fstrategy-on-implementing-a-shopping-cart-with-php-and-mysql%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            i have not worked on large e-com websites but i have implemented cart system with MySQL for many times, your approach is good if you want to do some machine learning with cart data.



            i use to delete data after some time interval (a week, a month) days if user has not checkout using cronjob.



            Or



            Send email to the user for checkout, if user done the same then okay else delete the data.



            Note:- This is just a suggestion.






            share|improve this answer


























              0














              i have not worked on large e-com websites but i have implemented cart system with MySQL for many times, your approach is good if you want to do some machine learning with cart data.



              i use to delete data after some time interval (a week, a month) days if user has not checkout using cronjob.



              Or



              Send email to the user for checkout, if user done the same then okay else delete the data.



              Note:- This is just a suggestion.






              share|improve this answer
























                0












                0








                0






                i have not worked on large e-com websites but i have implemented cart system with MySQL for many times, your approach is good if you want to do some machine learning with cart data.



                i use to delete data after some time interval (a week, a month) days if user has not checkout using cronjob.



                Or



                Send email to the user for checkout, if user done the same then okay else delete the data.



                Note:- This is just a suggestion.






                share|improve this answer












                i have not worked on large e-com websites but i have implemented cart system with MySQL for many times, your approach is good if you want to do some machine learning with cart data.



                i use to delete data after some time interval (a week, a month) days if user has not checkout using cronjob.



                Or



                Send email to the user for checkout, if user done the same then okay else delete the data.



                Note:- This is just a suggestion.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 9:45









                Ajit MauryaAjit Maurya

                465




                465






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408856%2fstrategy-on-implementing-a-shopping-cart-with-php-and-mysql%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Create new schema in PostgreSQL using DBeaver

                    Deepest pit of an array with Javascript: test on Codility

                    Fotorealismo