Modeling of customer, order and address entities

NopCommerce is a popular open-source shopping-cart based on ASP.NET.

To buy something the customer of online store should provide shipping and billing addresses. NopCommerce stores this information in a bit strange way. The figure below shows the simplified scheme of entities which are used to represent information about customers, orders and addresses.

 

The information about addresses is duplicated multiple times. Fields of the customer entity represent a main address of the customer. An instance of customer can be related to some addresses, each of which can be either a shipping address or a billing address. And an order also contains information about shipping and billing addresses.

I think that this data model should be significantly refined. The following figure shows an alternative solution:

nopaddressesuml2

I have moved all address data to the address entity. The customer entity continue to store first and last names because these fields can be helpful for displaying on some pages and sending personalized emails.

I’ve linked orders with addresses. And I’ve added a few fields to the address entity. Boolean attributes with names IsBillingAddress, IsShippingAddress and IsPostalAddress define a type of address (postal address will be the main address of the customer). The IsChangeable attribute defines whether the address can be changed by the customer later. I consider that an address should be unchangeable if it is related to an order.

  • Javier H. Mora

    “The IsChangeable attribute defines whether the address can be changed by the customer later. I consider that an address should be unchangeable if it is related to an order.”

    Thanks, I read all the article just for that sentence haha. Great article btw!