Binding two models / ORM modeling


#1

This may be more of a data-modeling question, but…

I am working on a hobby e-commerce project to learn ember. In my app, a customer can check out regardless of whether they set up an account.

If they don’t have an account: they populate the billing and shipping address models via via input

if they DO have an account: billing and shipping addresses need to come from their account user profile (“addresses” being a model with a belongs-to relationship to the “user” model)

The question is, do I COPY the addresses from the user’s address model or do I somehow bind them, perhaps like user.address = shipping.address so that they stay in sync throughout the order?

OR am I approaching the modeling incorrectly?


#2

We make copies of addresses, prices, descriptions, etc at the point in time when the ‘submit order’ event occurs so that you have a historical record of who/what/when/where of facts about the order. This is one of a rare set of use-case where you want to break the usual laws of data normalization.