Hi,

Just wanted to know, how the entity rule works in outsystems.

I have created enity like Customer (id, name, address, OrderId (reference entity), TransactionId (reference entity)) .. if I applied Protect Rule on OrderId and Delete Rule on TrasactionId then how rules will work?

Mean Protect Rule doesn't allow to remove referential record but delete allow. if Protect & Delete Rule apply on two different attributes in same entity then...


Thanks 

Hi Sheob,

Let me explain in details :

Suppose you have 3 entities : 

Customer : Id, name, orderId(protect),TransId(Delete)

Order : Id,orderAmount

Transaction : Id, TransType, TransAfmount

1. Now if you delete any customer then customer will be deleted without any issue.

2. But if you trying to delete an order which have, it will not allow and give error " The DELETE statement conflicted with the REFERENCE constraint "OSFRK_OSUSR_R9R_CUSTOMER_OSUSR_R9R_ORDER_ORDERID". The conflict occurred in database "YQOOGN054", table "dbo.OSUSR_R9R_CUSTOMER", column 'ORDERID'. The statement has been terminated."  Because here detele Rule is "Protect". So this order is protected because, this order have reference in customer.

3. If you try to delete any transaction, It will be deleted and related customer record will also be deleted.

Hopefully its clear to you now. If still have confusion let me know.

Thanks.

Not one the subject, but why would you want an orderid in the customer entity? I would think you need a customerid in the order entity.

I missed this, completely agree with Daniel. In order table you must have customer Id, as one customer may have many orders.

Thanks

Hi Shoeb,

Before answering your question I want to share that example entity structure you have share is not practical. Usually we keep customerid in order entity and orderid in transaction entity (for general scenarios).

Anyways, comming back to your doubt. You will see same behaviour as Vikas has shared.

Sheob Ahmad wrote:

Hi,

Just wanted to know, how the entity rule works in outsystems.

I have created enity like Customer (id, name, address, OrderId (reference entity), TransactionId (reference entity)) .. if I applied Protect Rule on OrderId and Delete Rule on TrasactionId then how rules will work?

Mean Protect Rule doesn't allow to remove referential record but delete allow. if Protect & Delete Rule apply on two different attributes in same entity then...


Thanks 


Hi Shoeb,


Yes, the OutSystems course has all the explanations with proper examples.

Please visit below URL,

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships


Thanks.