Modeling the rules
- Last Updated: March 26, 2025
- 3 minute read
- Corticon
- Version 7.1
- Version 6.3
- Documentation
In this example, we added data to the database for a flight plan for two cargo containers. An aircraft has been assigned to this flight plan.
You need to model rules to check if the flight plan is valid by comparing the total of the cargo weights with the maximum cargo weight of the aircraft as follows:
- If the total cargo weight is less than the maximum cargo weight of the assigned aircraft, the rule should throw an Info message.
- If the total cargo weight exceeds the maximum cargo weight of the assigned aircraft, the rule should throw a Violation message.
We need to create a Rulesheet by right-clicking on Cargo.ecore, and then choosing New > Rulesheet.
![]()
Name the Rulesheet CheckFlightPlanWeight, and then click Finish.
![]()
Fill in the Rulesheet as illustrated:
![]()
Here are the steps for this task:
- Choose the menu option Rulesheet > Advanced View.
- From the Vocabulary, drag and drop to the Scope panel:
- FlightPlan
- The FlightPlan association aircraft onto FlightPlan in the Scope, and then double click on it to open its alias entry box where you enter plane.
- The Aircraft attribute maxCargoWeight onto aircraft in the Scope.
- The FlightPlan association cargo onto FlightPlan in the Scope, and then double click on it to open its alias entry box where you enter load.
- The Cargo attribute weight onto cargo in the Scope.
- Write the condition load.weight->sum>plane.maxCargoWeight
- Select T in column 1 and F in column 2.
- Enter the rule statements as shown.
- Save the file.
Let’s look at the sample data that we want to retrieve. In SQL Server Management Studio, right-click the dbo.FlightPlan table and select Select Top 1000 Rows.
You should see the following result:
![]()
This retrieves one record—a FlightPlan with a flightNumber (the primary key of FlightPlan) set to 111, that is associated with an aircraft whose tailNumber is N111A.
Let’s look at the Aircraft records. Right-click the dbo.Aircraft table and select Select Top 1000 Rows. This should return one record:
![]()
Note that the tailNumber (which is Aircraft’s primary key) N111A, corresponds to the tailNumber of the associated aircraft in the FlightPlan’s record. Also, notice that the maximum cargo weight is 150000.
Now, let’s look at the cargo records. Right-click the dbo.Cargo table and select Select Top 1000 Rows. You should see the following records:
![]()
Note that in both records, the associated flightNumber is 111, which is same as the flightNumber of the FlightPlan record retrieved earlier. The sum of the cargo weight is 250000, which exceeds the maximum cargo weight of the Aircraft record.