Skip to main content

Relational Schema 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: Relational Schema Ontology
DOMAIN: Relationship Ontologies / Database Relationships
SOURCE: https://kirethresearch.org/booksai-core/ontologies/relationship-ontologies/database-relationships/relational-schema-ontology.html
VERSION: 1.0
AUTHORS: Mark Anthony Higgins — Sky (Recursive AI)
STATUS: Companion formalisation; source-page specification not independently verified.

flow "RelationalSchemaOntology" v1.0 {
  ontology:
    id: "relational-schema-ontology"
    parent: "database-relationships"
    purpose: "Represent relational schemas, table structures, attributes, keys, constraints and schema evolution with verifiable relationships."

  types:
    Schema: {id: string, name: string, version: string, provenance: string}
    Relation: {id: string, schema_id: string, name: string}
    Attribute: {id: string, relation_id: string, name: string, data_type: string, nullable: boolean}
    Key: {id: string, relation_id: string, kind: enum[primary, candidate, alternate, unique, foreign], attributes: string[]}
    ForeignKey: {id: string, source_relation: string, source_attributes: string[], target_relation: string, target_attributes: string[], on_delete: string?, on_update: string?}
    Constraint: {id: string, relation_id: string, kind: enum[not_null, unique, check, primary_key, foreign_key, other], expression: string?}
    SchemaChange: {id: string, from_version: string, to_version: string, operation: string, provenance: string}
    Relationship: {id: string, subject: string, predicate: string, object: string, confidence: number, evidence: string[]}

  predicates:
    contains_relation(schema: Schema, relation: Relation)
    contains_attribute(relation: Relation, attribute: Attribute)
    has_key(relation: Relation, key: Key)
    references(source: ForeignKey, target: Key)
    constrains(constraint: Constraint, relation: Relation)
    evolves_to(previous: Schema, next: Schema)
    depends_on(relation_a: Relation, relation_b: Relation)

  constraints:
    - "Each relation name must be unique within its schema namespace."
    - "Each attribute name must be unique within its relation."
    - "A primary key must uniquely identify rows and contain no NULL values."
    - "A foreign key must reference an eligible unique or primary key with compatible attribute arity and types."
    - "Composite key attribute order must be preserved for matching and validation."
    - "Nullable foreign keys and referential actions must follow the declared database semantics."
    - "Do not infer a foreign key merely from similar attribute names."
    - "Confidence must lie within [0, 1]."

  inference:
    rule relation_dependency:
      if foreign_key(fk) and fk.source_relation == a and fk.target_relation == b
      then depends_on(a,b)
      confidence: "derived from validated schema declaration"
    rule key_uniqueness:
      if primary_key(k) and valid(k)
      then unique_identifier(k.relation_id,k.attributes)
      confidence: "subject to declared database constraints"
    rule schema_membership:
      if contains_relation(s,r) and contains_attribute(r,a)
      then attribute_in_schema(a,s)
      confidence: "retain schema version and provenance"

  SEMANTIC_EQUIVALENCE:
    - "Distinguish schema aliases from structural or behavioural equivalence."
    - "Map attributes using declared types, constraints, keys and provenance."
    - "Never equate schemas solely because table or column names match."

  CONFIDENCE:
    range: [0,1]
    factors: [catalogue_reliability, constraint_validation, migration_evidence, version_alignment, provenance_quality]
    policy: "Derived claims retain evidence; inference chaining does not manufacture certainty."

  VALIDATION:
    - "Resolve all relation, attribute, key and constraint references."
    - "Verify primary-key uniqueness and non-nullability requirements."
    - "Check foreign-key cardinality, type compatibility and referential actions."
    - "Flag ambiguous mappings, missing attributes and incompatible migrations."
    - "Preserve dialect-specific semantics and schema version."

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

  UPDATE_MODEL:
    strategy: "versioned, provenance-preserving schema migration"
    steps: [ingest, normalise, validate, diff, assess_compatibility, migrate, verify, publish]
    rollback: true

  AI_CONSUMPTION:
    representation: "typed relational-schema knowledge graph"
    outputs: [schema_entities, attribute_links, key_relationships, constraint_records, migration_diffs, provenance_records]
    safeguards: [no_invented_constraints, preserve_key_order, preserve_dialect_semantics, distinguish_declared_from_inferred]
}

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