Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database Schema for Registered Customers and Guest Checkout

For an ecommerce site that allows both Guest checkouts and registered user checkouts, how will you handle the 2 different customer groups?

  1. Do you store both groups in the same table customers which has a foreign key customer_group_id pointing to another table customer_groups? In this case, will you worry about duplicate guest checkouts "polluting" the customers table?

  2. How will the information captured for the 2 customer groups be different? I am thinking the difference is that the guest checkout customers will not have a password thats it.

like image 911
Nyxynyx Avatar asked Oct 27 '25 05:10

Nyxynyx


1 Answers

I store customer information directly in the order rather than rely on the information in the customer record. That does a couple things:

  1. I don't have to have a guest user in the customer database
  2. If my customer information changes, or if a customer wants to ship one item to one place, and another item to another place the information about the order will still be correct.

I view order information as historical data. It should not change because something else in your database changes. For example if I order something from you, and at some later time I move and update my billing and shipping information, you should still know that the previous order was billed and shipped to the previous address. If you rely on the relationship between the customer and the order to retain bill to and ship to information, Once I move and update my profile, you think you shipped to my new address. You may not see that as an issue, but it will be.

You can still get the current information from the customer record to populate the fields on the order if the customer has an account. For a guest, he has to type it every time.

like image 124
jmarkmurphy Avatar answered Oct 29 '25 18:10

jmarkmurphy