Skip to main content

Database Relationship Ontology

Database Relationships
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 10 October 2026
Audio Overview
FLOW ALGEBRA
TITLE: Database Relationship Ontology
DOMAIN: Relationship Ontologies / Database Relationships
SOURCE: https://kirethresearch.org/booksai-core/ontologies/relationship-ontologies/database-relationships/database-relationship-ontology.html
VERSION: 1.0
AUTHORS: Mark Anthony Higgins — Sky (Recursive AI)
STATUS: Companion formalisation; source-page specification not independently verified.

flow "DatabaseRelationshipOntology" v1.0 {
  ontology:
    id: "database-relationship-ontology"
    parent: "database-relationships"
    purpose: "Represent, validate and reason over relational database structures, keys, constraints and associations."

  types:
    Database: {id: string, name: string, engine: string?, schema_version: string?}
    Table: {id: string, database_id: string, name: string}
    Column: {id: string, table_id: string, name: string, data_type: string, nullable: boolean}
    Key: {id: string, table_id: string, kind: enum[primary, foreign, unique, candidate], columns: string[]}
    Relationship: {id: string, source_table: string, target_table: string, kind: enum[one_to_one, one_to_many, many_to_many], source_columns: string[], target_columns: string[], optional: boolean, confidence: number, provenance: string[]}
    Constraint: {id: string, table_id: string, kind: enum[not_null, unique, check, referential, other], expression: string?}
    Query: {id: string, statement: string, schema_version: string?}

  predicates:
    belongs_to(column: Column, table: Table)
    has_primary_key(table: Table, key: Key)
    references(foreign_key: Key, target_key: Key)
    relates_to(source: Table, target: Table)
    constrained_by(table: Table, constraint: Constraint)
    joins_on(source: Table, target: Table, predicate: string)

  constraints:
    - "Every table and column reference must resolve within a declared schema."
    - "A primary key must be unique and non-null across its constituent columns."
    - "A foreign key must reference a compatible unique or primary key, subject to the database engine's supported rules."
    - "Composite keys preserve column order and full key membership."
    - "One-to-one cardinality requires an appropriate uniqueness constraint on the referencing side."
    - "Many-to-many relationships require an explicit association representation in a relational implementation."
    - "Optional relationships must preserve nullable and participation semantics."
    - "Do not infer a foreign key from similarly named columns alone."
    - "Confidence must lie within [0,1]."

  inference:
    rule foreign_key_association:
      if references(fk,pk) and valid(fk) and valid(pk)
      then relates_to(owner_table(fk),owner_table(pk))
      confidence: "derive from declared constraints and schema provenance"
    rule unique_foreign_key_cardinality:
      if references(fk,pk) and unique(fk.columns)
      then maximum_target_to_source_cardinality(pk,fk,1)
      confidence: "requires enforced uniqueness and consistent schema version"
    rule association_table_pattern:
      if references(fk_a,pk_a) and references(fk_b,pk_b) and same_table(fk_a,fk_b)
      then candidate_association_table(owner_table(fk_a))
      confidence: "heuristic only; do not assert many-to-many without further validation"

  SEMANTIC_EQUIVALENCE:
    - "Resolve aliases and naming conventions against schema-qualified identifiers."
    - "Distinguish conceptual relationships from enforced database constraints."
    - "Do not merge tables, keys or columns solely on lexical similarity."
    - "Preserve schema versions, datatype semantics and engine-specific behaviour."

  CONFIDENCE:
    range: [0,1]
    factors: [declared_constraints, schema_provenance, migration_history, data_quality, independent_validation]
    policy: "Treat declared, verified relationships differently from inferred candidates; never manufacture certainty."

  VALIDATION:
    - "Verify identifiers, column types, nullability, key uniqueness and foreign-key compatibility."
    - "Check referential integrity against the applicable database snapshot."
    - "Detect orphan references, invalid joins, circular dependencies and conflicting cardinalities."
    - "Report unenforced or engine-dependent constraints explicitly."
    - "Keep validation outcomes tied to schema version and provenance."

  FLOW_HASH:
    algorithm: "SHA-256"
    input: "canonicalised ontology version, schema declarations, relationships, rules and provenance"
    note: "Compute hash at execution; no hash value is claimed here."

  UPDATE_MODEL:
    strategy: "versioned, provenance-preserving incremental schema update"
    steps: [ingest, normalise, validate, compare_schema_versions, reconcile, recompute_inferences, publish]
    rollback: true

  AI_CONSUMPTION:
    representation: "typed schema graph with evidence-backed relationship edges"
    outputs: [table_entities, column_entities, key_links, relationship_triples, cardinality_annotations, validation_results, provenance_records]
    safeguards: [no_unverified_foreign_keys, preserve_nullability, respect_schema_versions, distinguish_inference_from_constraints]
}

END FLOW ALGEBRA
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ