The things this system keeps track of, the kinds of each, and the business rules that keep the data true. The rules are enforced automatically on every change, whether it comes from a screen, an API or a message. This page is generated from the system itself.
Each Department has many Employee records.
| Field | Kind of value | Notes |
|---|---|---|
| Name | text | required |
| Budget | amount | required |
| Total salary | amount | computed the total of its Employee salary |
Each Labor Union has many Employee records.
| Field | Kind of value | Notes |
|---|---|---|
| Name | text | required |
| Dues rate | number | required |
| Field | Kind of value | Notes |
|---|---|---|
| Name | text | required |
| Discount rate | number | |
| Tax rate | number | |
| Notes | text | |
| Max hourly weekly salary | number | |
| Military stipend per service year | number |
Each Employee belongs to one Department.
Each Employee has many Order records.
| Field | Kind of value | Notes |
|---|---|---|
| Name | text | required |
| Type | one of: salaried, hourly, commissioned | required |
| Salary | amount | computed hourly = hours worked * hourly rate; commissioned = base salary + commission total; salaried = entered value |
| Military | one of: yes, no | required |
| Total compensation | amount | computed salary + military stipend for military employees; salary for non-military |
Each Order belongs to one Employee.
| Field | Kind of value | Notes |
|---|---|---|
| Customer name | text | required |
| Amount | amount | required |
They are classified in independent ways. Each record is exactly one kind on each way that is exclusive, and may also be a kind from the others.
Exactly one of these:
No additional fields.
May have one Labor Union. No other kind of employee can.
| Field | Kind of value | Notes |
|---|---|---|
| Hours worked | number | |
| Hourly rate | number | |
| Union dues | amount | computed hours worked * union dues rate for hourly employees with a union, else 0 |
| Field | Kind of value | Notes |
|---|---|---|
| Base salary | amount | |
| Commission total | amount | computed the total of its Order amount |
| Order count | whole number | computed the number of its Order records |
Independent of the other classifications:
| Field | Kind of value | Notes |
|---|---|---|
| Branch | one of: Army, Navy, Air Force, Marines, Coast Guard | |
| Rank | text | |
| Service years | whole number | |
| Military stipend | amount | computed service years * the system setting military stipend per service year for military employees, 0 otherwise |
Each rule traces to the requirement that asked for it. added by AI marks rules the requirement did not state, so a person should confirm them (the judgment calls are listed in ad-libs.md).
| Rule | Type | Requirement |
|---|---|---|
| Department total salary: the total of its Employee salary | Total | Department.total_salary = sum of Employee.salary (all types). |
| Total salary must not exceed budget, unless the committing user holds the manager role | Check | Department.total_salary must not exceed Department.budget. If violated: Department total salary ([total salary]) exceeds budget ([budget]) - only the manager role may exceed the budget |
| Rule | Type | Requirement |
|---|---|---|
| Employee salary: hourly = hours worked * hourly rate; commissioned = base salary + commission total; salaried = entered value | Calculation | Hourly employees: salary = hours_worked * hourly_rate. / Commissioned employees: salary = base_salary + commission_total. |
| Employee union dues: hours worked * union dues rate for hourly employees with a union, else 0 | Calculation | Hourly employees: union_dues = hours_worked * union.dues_rate (0 if no union assigned). |
| Employee commission total: the total of its Order amount | Total | Commissioned employees: commission_total = sum of Order.amount. |
| Employee order count: the number of its Order records added by AI | Count | (not stated in the requirement) |
| Employee type must be one of: salaried, hourly, commissioned | Check | Employees have a type that is one of: 'salaried', 'hourly', or 'commissioned'. If violated: Employee type ([type]) must be one of: salaried, hourly, commissioned |
| An hourly employee's (weekly) salary must not exceed the system setting max hourly weekly salary | Check | Hourly employees: salary must not exceed 5000 per week. If violated: Hourly employee salary ([salary]) exceeds the weekly maximum (the system setting max hourly weekly salary) |
| Only hourly employees may have a union id | Check | Hourly employees may be assigned to a Union (optional); only Hourly employees may have a union_id. Applies to: Hourly Employee If violated: Only hourly employees may have a union id |
| Only commissioned employees may have Orders | Check | Commissioned employees are employees who can have Orders; only Commissioned employees may have Orders. Applies to: Commissioned Employee If violated: Only commissioned employees may have Orders (order count is [order count]) |
| Hours worked must be null for non-hourly employees added by AI | Check | (not stated in the requirement) Applies to: Hourly Employee If violated: hours worked must be null for non-hourly employees |
| Hourly rate must be null for non-hourly employees added by AI | Check | (not stated in the requirement) Applies to: Hourly Employee If violated: hourly rate must be null for non-hourly employees |
| Base salary must be null for non-commissioned employees added by AI | Check | (not stated in the requirement) Applies to: Commissioned Employee If violated: base salary must be null for non-commissioned employees |
| Rule | Type | Requirement |
|---|---|---|
| Employee military stipend: service years * the system setting military stipend per service year for military employees, 0 otherwise | Calculation | Military employees receive a military_stipend (REAL) = service_years * 100. / Total compensation for military employees = salary + military_stipend. |
| Employee total compensation: salary + military stipend for military employees; salary for non-military | Calculation | Total compensation for military employees = salary + military_stipend. |
| Military must be 'yes' or 'no' added by AI | Check | (not stated in the requirement) If violated: military ([military]) must be 'yes' or 'no' |
| Branch must be one of: Army, Navy, Air Force, Marines, Coast Guard | Check | Military employees have a branch (TEXT: 'Army', 'Navy', 'Air Force', 'Marines', 'Coast Guard'), If violated: branch ([branch]) must be one of: Army, Navy, Air Force, Marines, Coast Guard |
| Branch must be null for non-military employees added by AI | Check | (not stated in the requirement) Applies to: Military Employee If violated: branch must be null for non-military employees |
| Rank must be null for non-military employees added by AI | Check | (not stated in the requirement) Applies to: Military Employee If violated: rank must be null for non-military employees |
| Service years must be null for non-military employees added by AI | Check | (not stated in the requirement) Applies to: Military Employee If violated: service years must be null for non-military employees |
Where each calculated value comes from, and what a change ripples to. The same information is in lineage.csv and lineage.json for catalog tools.
| This value | is calculated from |
|---|---|
| Department total salary | Employee salary |
| Employee salary | Employee type, Employee hours worked, Employee hourly rate, Employee base salary, Employee commission total |
| Employee union dues | Employee type, Employee union id, Employee hours worked, Labor union dues rate |
| Employee commission total | Order amount |
| Employee order count | Order records |
| Employee military stipend | Employee military, Employee service years, Sys config military stipend per service year |
| Employee total compensation | Employee military, Employee salary, Employee military stipend |
| If this changes | these are recalculated |
|---|---|
| Employee type | Employee salary, Employee union dues, Department total salary, Employee total compensation |
| Employee hours worked | Employee salary, Employee union dues, Department total salary, Employee total compensation |
| Employee hourly rate | Employee salary, Department total salary, Employee total compensation |
| Employee base salary | Employee salary, Department total salary, Employee total compensation |
| Employee union id | Employee union dues |
| Labor union dues rate | Employee union dues |
| Order amount | Employee commission total, Employee salary, Department total salary, Employee total compensation |
| Order records | Employee order count |
| Employee military | Employee military stipend, Employee total compensation |
| Employee service years | Employee military stipend, Employee total compensation |
| Sys config military stipend per service year | Employee military stipend, Employee total compensation |
All 12 records in the system satisfy every check that can be stated as a standard SHACL shape (demo_emp_types.shapes.ttl).
Technical files in this folder: demo_emp_types.ttl, demo_emp_types.shapes.ttl, genai-logic.ttl, lineage.csv, lineage.json.