2. Business Rules Business rule is “rule that is under business jurisdiction” (Object Management Group, 2008) Constraints are ways to enforce business rules. Conceptual graphs and logical expression provide a path to translate constraints into physical level implementation. SBVR is a formal standard developed by OMG to define business vocabulary and describe rules based on the vocabulary. 2
3. Constraint 3 : Conceptual Graph A pickup biker cannot pickup a consignment in a district which she/he does not cover. 3
4. Constraint 3: Logical Expression Logical Expression: not (a valid concept PB of type ‘Pickup Biker’ and a valid concept DP of type ‘Dispatch Parcel’ and a valid concept DD of type ‘District Division’ and a valid concept PC of type ‘Parcel of Consignment’ and a valid concept PD of type ‘Pickup District’ such that PB.Employeeo DD.Employeeand PB.Dispatch Parcel o DP and DP.Parcel of Consignment o PC and PC.Consignmento PD.Consignmentand PD.District <> DD.District) 4
6. Constraint 3: Trigger CREATE TRIGGER [PICKUP_BIKER_COVERS_PICKUP_DISTRICT] ON [DISPATCH_PARCEL] FOR INSERT, UPDATE AS IF EXISTS (SELECT DP.CONSIGNMENT_NR FROM DISPATCH_PARCEL DP INNER JOIN EMPLOYEE E ON DP.PICKUP_BIKER = E.EMPLOYEE_NR INNER JOIN INSERTED I ON I.PICKUP_BIKER = E.EMPLOYEE_NR INNER JOIN CONSIGNMENT C ON C.CONSIGNMENT_NR = DP.CONSIGNMENT_NR WHERE C.PICKUP_DISTRICT_NAME <> E.DISTRICT_NAME ) BEGIN RAISERROR 4000005 'THE PICKER BIKER DOES NOT COVER THE PICKUP DISTRICT.' ROLLBACK END 6
7. Constraint 4: Conceptual Graph The delivery time of a dispatch parcel must not be equal or smaller than the pickup time of that dispatch parcel. 7 Logical Expression: not (a valid concept DDT of type ‘Dispatch Delivery Time’and a valid concept DPT of type ‘Dispatch Pickup Time’such that DDT.DispatchParcel o DPT.Dispatch Parcel and DDT.Date_Time<= DPT.Date_Time)
9. Constraint 4: Check Constraint ALTER TABLE DISPATCH_PARCEL WITH CHECK ADD CONSTRAINT DISPATCH_DELIVERY_TIME_LATER_THAN_PICKUP_TIME CHECK ((DISPATCH_D > DISPATCH_P)) 9
10. Reflection Business rules are easy to express in natural language but difficult to implement. It is better to write rules as what is not wanted (negative statements). A well designed repository of business rules in form of logical expression can help to automate implementation (active approach). 10