I have a simple ecommerce type site that will have users with accounts, orders, and contact/billing information for those users. I just wanted to know the best way to setup these tables from an efficiency and logical point of view. So far I have basically two different entities, users and orders. Users will have basic account information like name and password, Orders will contain all the information about the certain order.
My question is, should I include all contact/billing information within the User table or make two separate tables to contain contact and billing information?
You might have to think about this a little more:
Users have a contact and billing address, what about shipping and other addresses? Is it possible to have two users from one company, each with different contact addresses but the same billing address? Is it possible for one user to have multiple billing addresses that they will choose at the time of order?
Then when it comes to your orders, what happens if a customer updates his billing address, and then you pull up an order from before the billing address changed. Should the billing address on the old order be the new one, or the one from the time of the order?
If the problem is as simple as you describe, and a user simply has contact and billing addresses, and there are no other ‘what ifs’, then it makes sense to just put those addresses in the user’s table. From my limited experience in this domain, however, you may very well find that addresses need to be entities in their own right, separate from specific users. In fact, it may be that you think of a ‘user’ as a ‘contact address’.