How to store one entitys data into another entity

I am creating an app where customers can buy various products. I have created a  cart entity where I want to store data temporarily. I am passing the data into an order entity where the order id and other order details are present. When I will purchase products from the order entity the data into the cart should be cleared. Hence I need another entity to store the ordered data so that customer can see their placed order details. Hence I have taken another entity OrderDetails where the placed order data is shown to the customer.
3 answers

It seems like you already found a solution. What is your question? is something not working as expected?



Hello, Ishwari 
Maybe you forget that to create an association of those entities you have to store data temp. then it necessary for association 
I attached the following more information doc so see helpful you,the%20target%20of%20the%20association.


Hi Ishwari,

Seeing your comment on Andreas, it seems you are struggling how to store the order after the customer purchased the item and the cart is empty again. I recommend you to create an entity called ‘Orderline’ with an association to Order. I recommend this object contains at least the following attributes: Quantity, ProductCode, Price. Additionally, but not necessarily, ‘ProductName’ and/or ‘DiscountApplied’.

You really want to separate the products you have for sale and orders that have been made. This would basically mean that you’ll have two entities of ‘Product’, one for those you are selling and those that are associated to orders. The reason for this is history. If you’d change the price or productcode and your order has an association to a single object of Product, the order will change and not reflect the actual purchase that has been made.

In addition, I also recommend to separate items that are in cart and are associated to an order. Basically, copy the items from ‘In cart’ to ‘Ordered’ and empty the objects that are ‘in cart’, i.e. VendingMachineProduct. 

This way you have ‘Product for sale’, Product in cart’ and ‘product ordered’. Whereas ProductInCart could in fact be a non-persistent object (unless you want to keep the cart contents after closing the browser session). 

You might want to check for some examples regarding Orderlines.

Good luck!