Skip to content

Constraints: revisit CHECK only if a write bypasses BerlinDB (expression-layer, not Kern) #236

Description

@JJJ

Background

From the #232 layering discussion (Kern = declared nouns). Today the constraint surface is split: Index covers UNIQUE KEY, Relationship covers FOREIGN KEY, and a standalone CHECK constraint is not modeled at all. A unified Constraint object (or a broadened story across Index/Relationship) would let a developer declare table constraints uniformly - which puts it on the Kern axis.

Sketch (not committing to a shape)

  • A declared constraint carrying a kind (CHECK / UNIQUE / FOREIGN KEY), its columns/expression, and a name, that emits its DDL fragment - much like Index::get_create_string() / Relationship::get_create_string().
  • Decide the boundary: does this replace the UNIQUE-via-Index and FK-via-Relationship paths, or only add CHECK alongside them? (Likely add CHECK; keep Index / Relationship as-is to avoid churn - reconcile in design.)
  • Cross-engine caveat (Audit: cross-engine SQL compatibility (MySQL/MariaDB dialect assumptions across generated SQL) #220): CHECK enforcement differs (older MySQL parsed-but-ignored it; MariaDB and MySQL 8.0.16+ enforce; SQLite supports it) - validate before relying, do not assume.

Status

YAGNI until a feature needs CHECK; filed to capture the axis + the current split. Related: #232, #220, and the FK work in #205 / #193.

Metadata

Metadata

Assignees

No one assigned

    Labels

    object: ClauseClause value objects (Where/Join/BooleanGroup/Predicate/Builder).object: IndexIndex definitions and index management.object: RelationshipRelationship definitions, foreign keys, and related-data loading.status: Needs ResearchNeeds investigation before implementation.type: FeatureNew capability or behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions