Skip to content

SQL schema - clashing enums across repositories #35

Closed

Description

@rokf

Hello,

We're trying to use SQL schema files from multiple Smart Data Model Git repositories and we've noticed that in some occasions unrelated enums with the same name are defined. This means that it is currently impossible to apply all the Smart Data Model schema files to the same PostgreSQL database because some of them have clashing "building blocks".

Let's take the status_type enum as an example. It's defined in at least two model repositories - the DCAT-AP one and the Device one:

In the Distribution SQL schema the status_type is defined as:

CREATE TYPE status_type AS ENUM ('Completed','Deprecated','Under Development','Withdrawn')

In the DeviceOperation SQL schema it is defined as:

CREATE TYPE status_type AS ENUM ('cancelled','finished','ongoing','planned','scheduled');

Could enums either be rewritten in such a way that they wouldn't clash even if one applies all the available Smart Data Model SQL schema files to a single database? Alternatively they could be removed and replaced with a regular text column? A name change would also work I suppose but ending up with very long (but unique) enum names might not be something we'd want in the long run?

Maybe value constraints (checks) for columns could be a good enough alternative? I.e.

status TEXT NOT NULL CHECK (status IN ('cancelled','finished','ongoing','planned','scheduled')),

https://www.postgresql.org/docs/current/ddl-constraints.html

Thank you!

Activity

  1. albertoabellagarcia commented on Sep 3, 2025

    @albertoabellagarcia
    Contributor

    There is a simple explanation for this. The people uses same terms for different things. Linked data make this attributes unique but the raw SQL export is true that present inconveniences.
    However being in different models it should be different tables and therefore its use possible.
    At SDM don't have unique attributes names because the world is this way, imperfect, and our goal is to normalize the real world not an imaginary world that it is not existing. In sql I know that it is possible to have the table as prefix and would not this be a solution?

  2. rokf commented on Sep 4, 2025

    @rokf
    Author

    In sql I know that it is possible to have the table as prefix and would not this be a solution?

    I suppose that you mean something like:

    • Distribution_status_type
    • DeviceOperation_status_type

    This should work as well, yes. It'd make them unique and we could apply both schema files to the same database without modifications.

  3. albertoabellagarcia commented on Oct 7, 2026

    @albertoabellagarcia
    Contributor

    Fixed -- see smart-data-models/data-models#74 for the implementation details. Both examples from this issue are verified live now:

    -- dataModel.DCAT-AP/Distribution
    CREATE TYPE Distribution_status_type AS ENUM ('Completed', 'Deprecated', 'Under Development', 'Withdrawn');
    -- dataModel.Device/DeviceOperation
    CREATE TYPE DeviceOperation_status_type AS ENUM ('cancelled', 'finished', 'ongoing', 'planned', 'scheduled');

    All 272 affected models across the published catalog have been regenerated with the entity-prefixed naming you and rokf agreed on here. Thanks for identifying this and proposing the fix.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions