Skip to main content

Query Ontology

Database Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 11 November 2026
Audio Overview
KIRETH RESEARCH — SEMANTIC LIBRARY
QUERY ONTOLOGY — FLOW ALGEBRA v1.0
Category: Computational Entities > Database Entities
Authors: Mark Anthony Higgins — Sky Recursive AI
Source: https://kirethresearch.org/booksai-core/entity-graph/computational-entities/database-entities/query-ontology.html
Prepared: 11 November 2026
Status: Constructed ontology-level Flow Algebra mapping; not a transcription of hidden page specifications.

1. PURPOSE
Model a database query as a typed, context-bound request transformed into a validated execution plan, evaluated against a database snapshot, and returned as a result or explicit failure.

2. HST STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = query text/AST, parameters, schema metadata, available statistics, execution context.
R_t = parsing, binding, type-checking, rewriting, planning, execution, validation rules.
B_t = permissions, transaction isolation, resource budgets, supported dialect, time limits.
K_t = known schema, indexes, constraints, plan statistics, provenance, prior verified outcomes.

Expansion: E_t = expand(I_t, R_t)
Valid candidates: V_t = {x in E_t | satisfies(x, B_t)}
Selection: x*_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t)
Update: I_(t+1) = update(I_t, x*_t, observed_result)
Note: P is an abstract selection score, not necessarily a calibrated probability.

3. ENTITY GRAPH
Query --targets--> Database
Query --references--> Table / View / Column
Query --contains--> Predicate / Projection / Join / Aggregation / Ordering
Query --binds--> Parameter
Query --isParsedInto--> Abstract Syntax Tree
Query --isValidatedAgainst--> Schema / Type / Permission
Query --isOptimisedInto--> Execution Plan
Execution Plan --uses--> Index / Scan / Join Operator
Execution Plan --executesWithin--> Transaction / Snapshot
Execution --produces--> Result Set / Mutation Count / Error
Result --records--> Provenance / Timing / Diagnostics

4. FORMAL OPERATIONS
Parse(q, grammar) -> AST | SyntaxError
Bind(AST, schema, params) -> BoundAST | BindingError
Authorise(BoundAST, principal, policy) -> Allowed | Denied
Rewrite(BoundAST, equivalence_rules) -> CandidatePlans
ChoosePlan(CandidatePlans, statistics, budget) -> Plan
Execute(Plan, snapshot, resources) -> Result | ExecutionError
Validate(Result, expected_shape, constraints) -> Accepted | Rejected

5. QUERY EXECUTION FLOW
F0: Receive query, parameter values and identity.
F1: Parse syntax; reject malformed expressions.
F2: Resolve table, column and function names.
F3: Type-check operands, expressions and parameter bindings.
F4: Check privileges and policy boundaries.
F5: Generate semantics-preserving candidate plans.
F6: Select a feasible plan under estimated cost and resource limits.
F7: Execute within the declared transaction and isolation context.
F8: Apply result-shape, integrity and error checks.
F9: Return result with provenance and diagnostic status.
F10: Update permitted planning statistics without leaking sensitive query data.

6. INFERENCE RULES
IF a referenced relation is absent THEN reject with BindingError.
IF a parameter violates its declared type THEN reject before execution.
IF access policy denies an operation THEN execution is prohibited.
IF an index supports a selective predicate THEN consider an index access plan; do not assume it is always faster.
IF a query modifies rows THEN enforce applicable constraints and transaction semantics.
IF execution exceeds a hard resource boundary THEN cancel or fail according to policy.
IF the result is incomplete THEN do not label it complete.

7. MINI RECURSION ENGINE
State X_t = (unresolved_nodes, candidate_plans, verified_constraints, budget).
Step(X_t): resolve one outstanding AST/plan dependency, propagate constraints,
            expand feasible alternatives and prune invalid branches.
Stop when unresolved_nodes is empty, a valid plan is found, or budget exhausted.
Invariant: each accepted transformation preserves the query's declared semantics.
Termination guarantee is conditional on finite plan search or enforced step limits.

8. CORRECTNESS AND BOUNDARIES
- Preserve relational semantics, including NULL and three-valued logic.
- Respect ordering only where explicitly defined.
- Distinguish logical equivalence from physical performance equivalence.
- Never assume deterministic results without sufficient ordering and isolation conditions.
- Maintain parameterisation to reduce injection risk.
- Respect row-level security and least-privilege permissions.
- Treat statistics as estimates, not proof of runtime cost.
- Separate committed state from uncommitted changes under the active isolation level.

9. TRI-MAPPING
Entity: Query | Relationship: references schema | Flow: bind names and types
Entity: Predicate | Relationship: filters relation | Flow: evaluate condition
Entity: Plan | Relationship: implements query | Flow: execute physical operators
Entity: Transaction | Relationship: scopes execution | Flow: read/write under isolation
Entity: Result | Relationship: derives from execution | Flow: validate and return

10. EXECUTION GUARANTEE
Given a valid query, authorised identity, compatible schema, adequate resources,
well-defined transaction semantics and a correct database engine, execution returns
an engine-defined result or an explicit error. No unconditional success, optimality,
termination or completeness guarantee is asserted.

11. CITATION AND LICENCE
Source attribution: Mark Anthony Higgins — Sky Recursive AI.
Canonical source URL: https://kirethresearch.org/booksai-core/entity-graph/computational-entities/database-entities/query-ontology.html
Refer to the published Kireth Research Open Research Licence for reuse terms.
This TXT file is a newly constructed interpretive mapping; verify against the
full original ontology specification before treating it as canonical.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ