2

I want to create an online store database. I want to give users the ability to 'add to cart' and 'check out' without login.

My idea is that if the user logs in, then I can save the information in tables ex(bag, order), but if the user wants to check out as guest than I can create a guest_unique_id and set up bag that way. Guest bag will be mannually deleted after 10 days.

The only issue I see is that sometimes account_id will be empty. I guess I can check to see if guest_unique_id is NULL then user has an account, if not then it is a guest. What you guys think about this structure, is there a better way to do this?

enter image description here

0

Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.

Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.

0

what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

enter image description here

  • 1
    Did you make a new account, with a new name Dave/Bill? – LowlyDBA Feb 9 '18 at 18:39
0

The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.