FLOW ALGEBRA
TITLE: Many-to-Many Relationship Ontology
DOMAIN: Relationship Ontologies / Database Relationships
SOURCE: https://kirethresearch.org/booksai-core/ontologies/relationship-ontologies/database-relationships/many-to-many-relationship-ontology.html
VERSION: 1.0
AUTHORS: Mark Anthony Higgins — Sky (Recursive AI)
STATUS: Companion formalisation; source-page specification not independently verified.
flow "ManyToManyRelationshipOntology" v1.0 {
ontology:
id: "many-to-many-relationship-ontology"
parent: "database-relationships"
purpose: "Model, enforce and explain many-to-many associations between typed database entities through explicit relationship records."
types:
EntityType: {id: string, name: string, primary_key: string}
EntityInstance: {id: string, type_id: string, key: string}
JunctionTable: {id: string, name: string, left_fk: string, right_fk: string, uniqueness: string[]}
Association: {id: string, left: string, right: string, junction_id: string, attributes: map?, provenance: string?, confidence: number?}
Cardinality: {min: integer, max: integer?}
Constraint: {id: string, kind: enum[foreign_key, unique, not_null, check, cascade_policy], expression: string}
predicates:
many_to_many(left_type: EntityType, right_type: EntityType)
mediated_by(left_type: EntityType, right_type: EntityType, junction: JunctionTable)
references(association: Association, entity: EntityInstance)
associated_with(left: EntityInstance, right: EntityInstance)
has_cardinality(entity_type: EntityType, role: string, cardinality: Cardinality)
constraints:
- "Each junction row references one valid instance on each side unless an explicitly documented staging policy permits unresolved references."
- "A composite UNIQUE(left_fk, right_fk) or equivalent key prevents duplicate pairs when the relationship is set-valued."
- "Repeated pairs are allowed only when an additional discriminator is explicitly part of the association identity."
- "Foreign keys and referenced primary or candidate keys must have compatible types and enforce referential integrity."
- "Many-to-many cardinality permits multiple partners on both sides; minimum participation (zero or one) must be specified separately."
- "Deleting a referenced entity must follow an explicit RESTRICT, CASCADE or other supported referential action policy."
- "Association does not imply equality, causality or transitivity."
inference:
rule association_from_junction:
if valid(junction_row) and references_left(junction_row,a) and references_right(junction_row,b)
then associated_with(a,b)
confidence: "retain source-row provenance; no invented certainty"
rule reverse_navigation:
if associated_with(a,b) and relation_is_bidirectionally_navigable(a,b)
then navigable_from(b,a)
confidence: "same evidence, inverse role semantics preserved"
rule participation_count:
if valid_associations_for(entity, role, rows)
then participation(entity,role,count_distinct(rows))
confidence: "computed from validated rows and query snapshot"
SEMANTIC_EQUIVALENCE:
- "Map junction-table and associative-entity representations only when keys, roles, attributes and constraints are preserved."
- "Distinguish relation direction and role names from semantic symmetry."
- "Never merge entities based only on shared associations."
CONFIDENCE:
range: [0,1]
factors: [referential_integrity, provenance_quality, temporal_validity, source_reliability]
policy: "Schema constraints are deterministic; confidence annotations apply to uncertain source assertions, not to proven key checks."
VALIDATION:
- "Verify endpoint existence, key compatibility, uniqueness policy and cardinality bounds."
- "Detect orphan junction rows, duplicate pairs, unexpected null keys and inconsistent role mappings."
- "Test insert, update and delete behaviour against declared referential actions."
- "Retain junction attributes and provenance during graph conversion."
FLOW_HASH:
algorithm: "SHA-256"
input: "canonicalised ontology version, schema, constraints, typed associations and provenance"
note: "Compute at execution; no hash value is claimed here."
UPDATE_MODEL:
strategy: "versioned, integrity-preserving incremental updates"
steps: [ingest, normalise, validate_keys, enforce_constraints, reconcile, update_associations, publish]
rollback: true
AI_CONSUMPTION:
representation: "typed relational associations with knowledge-graph projection"
outputs: [entity_links, junction_records, role_aware_edges, cardinality_metadata, integrity_reports, provenance_records]
safeguards: [no_unverified_entity_merges, no_automatic_transitivity, preserve_junction_attributes, enforce_referential_integrity]
}
END FLOW ALGEBRA
Download Code
Copy to Clipboard