Skip to content

Explore: expand Schema to carry relation-level properties beyond columns/indexes #238

Description

@JJJ

Background

Fell out of the #235 (View) / #237 (Table decomposition) design. Today the declaration split is:

  • Schema = structure: columns, indexes, relationships.
  • Table = physical attributes + lifecycle: engine, charset/collation, row_format, auto_increment, comment, name/prefix, install/version.

The View work surfaced the first relation-level policy that naturally wants to live with the declaration a Query consumes: read-only. A Query already holds its table_schema, so read-only-ness should be DERIVED from the schema (Query::can_write() reads Schema::is_read_only(), Crud gates writes), not declared per-call - so a caller never has to know it is querying a view. That is landing as part of the View work: a read_only Schema property (default false; a view's schema sets it true).

The broader question

read_only is the first property to cross the columns/indexes boundary on Schema. Should Schema become the SINGLE relation-declaration surface - also carrying attributes that currently live on Table (engine, charset/collation, row_format, comment, ...)? That would make Schema the one thing a developer declares and both Table/View and Query consume, instead of splitting structure (Schema) from physical attributes (Table).

Appealing, but non-trivial:

  • BC: Table's engine/charset_collation/etc. config keys are @since released; moving their home needs care (accept on both, or deprecate).
  • Some attributes are genuinely Table-only (engine has no meaning for a view), so it is not a clean lift-and-shift - it is "which properties are relation-declaration vs installer-specific."
  • Interaction with Decompose Table into shared storage/relation traits (foundation for View #235) #237 (the shared Storage traits) and the declare-vs-discover axis (CLAUDE.md).

Scope

Research/design only. The read_only property ships with #235 regardless; this issue tracks whether to generalize the pattern. Related: #235, #237, #232.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: Database/KernCore database objects in src/Database/Kern.object: SchemaSchema objects, table definitions, and schema comparison.status: Needs ResearchNeeds investigation before implementation.type: ImprovementRefinement to existing behavior, code, or APIs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions