Skip to content

core-spec relationships have no cardinality field #694

Open

Description

@marioapiphani

spec.md relationships carry from, to, from_columns, to_columns, and nothing that declares whether the relationship is to-one or to-many. The ontology layer has multiplicity (ManyToOne, OneToOne); the core model has no equivalent, so a model that never reaches Layer 4 cannot say "a customer has many sales areas; each sales area belongs to one customer" except as prose.

Sources like SAP CSN always declare cardinality on associations (cardinality: { max: '*' }, managed to-one), and never infer it. Two consequences today: a CSN → core-spec converter must drop it (apache/ossie-converters#54 keeps it in the SAP_CSN extension, which is the right workaround and also the symptom); and the portability ladder cannot grade it, because there is nothing in the document to grade.

#246's relational semantics infer join cardinality from keys (unique_keys, §6.4), which covers evaluation but not declaration. Request: an optional declared cardinality on core-spec relationships — minimum to_one | to_many per side, or the ontology layer's Multiplicity reused — and a rule that declared-vs-inferred disagreement is a typed error, not silent trust of either side. Raised earlier in Discussion #50 from the ontology side; this is the core-spec half.

Activity

  1. marioapiphani commented on Nov 4, 2026

    @marioapiphani
    ContributorAuthor

    Reference update, since #246 was closed today as superseded by #653: the §6.4 inference rule I cited (cardinality derived from from_columns/to_columns against primary_key/unique_keys) lived in foundational_semantics.md on the #246 branch and was not carried over; it has no current location on main.

    What main has instead makes this issue sharper rather than moot. relational_semantics.md §11.3 now gives Layer 2 relationships a declared cardinality (ONE_TO_ONE, ONE_TO_MANY, MANY_TO_ONE, MANY_TO_MANY), described as informational only and not enforced; §3.4 maps a core-spec relationship onto it as from-many / to-one; and §13.2 leaves it open which of those elements the core model should carry. So the spec now has the field one layer up, with no enforcement, while the layer where sources declare it still can't. The request stands: declare it at the core model, let Layer 2 inherit it, and make declared-vs-inferred disagreement a typed error rather than "informational".

  2. christianeu-db commented on Nov 5, 2026

    @christianeu-db
    Contributor

    FYI, there is a thread here about adding cardinality.

    Layer 2's cardinality is proposed as a future extension - it's not part of that spec yet. There, the metadata is designed informational. The SQL extension itself (measure-typed columns) ensures that values aren't duplicated - even if the declared cardinality is wrong.

    Layer 3 (the more BI-like wide-table semantic) is what would most benefit from the cardinality flag since that's often used as one factor in determining join paths.

  3. marioapiphani commented on Nov 10, 2026

    @marioapiphani
    ContributorAuthor

    Thanks — I had missed the dev@ thread, and I also overstated §11.3 in my last comment: as you say, it's a proposed extension, not current spec. The proposal on the list (multiplicity on core-spec relationships, ManyToOne / OneToOne, same name as the ontology layer) is what this issue asks for, so I'll take the remaining points there rather than fork the discussion. Happy for this to be closed as covered by the thread, or kept as the tracker for the schema PR — whichever the maintainers prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs triage by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions