1.5 Create and Display One-to-One Relationships

1.5 Create and Display One-to-One Relationships

  
Why not add shippingdetail attribute in the order entity?
Hi joop,

Our main goal in this lesson is to show how to create one-to-one relationships, we do not want to get into deep discussion about when and why to create them. Nonetheless adding an attribute of 5000 chars to the Order entity could lead to slower accesses to the database to fetch the orders, specially if you bring alont that attribute. Having it in a separate entity forces the developer to take the decision of when to fetch it from the database.
André Vieira wrote:
Hi joop,

Our main goal in this lesson is to show how to create one-to-one relationships, we do not want to get into deep discussion about when and why to create them. Nonetheless adding an attribute of 5000 chars to the Order entity could lead to slower accesses to the database to fetch the orders, specially if you bring alont that attribute. Having it in a separate entity forces the developer to take the decision of when to fetch it from the database.
 Ty for your answer. All Clear to me. 
 
Hello,
At around minute 4, an error ocurred in the video because we needed to be more specific in the record to fetch.
This error didn't appear in my case, so does this problem only happen in older versions? Should i change it like in the video or leave it as it is?

Best Regards,
Hugo Martins
Hi Hugo,

You are correct, around 3:39 we have an error that no longer occurs. Now the CreateOrUpdateOrder action accepts Form.Record as a value taking from it the Order it contains. Under the hood what's happening is an implict conversion between the Order, ShippingDetails record to an Order record.

You can make the change you see in the video, Form.Record.Order and the implicit conversion is no longer used because you are now providing the data type expected by the CreateOrUpdateOrder action which is an Order or you can leave it as you have and an implict conversion is used.

I hope this makes it clear.
Cheers
Thanks for the answer André.

Then if i'm understanding correctly, even in cases where only one type of record exists i can still chose that type (for example Form.Record.OrderItem in OrderItemDetail Save action) instead of choosing the record (Form.Record). As to avoid the implicit conversions in case of form change (since i think it's good practice to be as explicit as possible whenever you can).

Best Regards,
Hugo Martins
You are correct Hugo.