uuid6 / uuid6-ietf-draft

Next Generation UUID Formats
https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
187 stars 11 forks source link

Encouraging the use of UUID as the primary key #112

Closed sergeyprokhorenko closed 1 year ago

sergeyprokhorenko commented 2 years ago

Change Proposal

Source (Select one.)

Change Reason (Select all that apply.)

Draft Number, Full Section, Name

Section 6.9. DBMS and Database Considerations

Current Text:

DBMS vendors are encouraged to provide functionality to generate and store UUID formats defined by this specification for use as identifiers or left parts of identifiers such as, but not limited to, primary keys, surrogate keys for temporal databases, foreign keys included in polymorphic relationships, and keys for key-value pairs in JSON columns and key-value databases.

Proposed Text:

DBMS vendors are encouraged to provide functionality to generate and store UUID formats defined by this specification for use as identifiers or left parts of identifiers such as, but not limited to, primary keys, surrogate keys for temporal databases, foreign keys included in polymorphic relationships, and keys for key-value pairs in JSON columns and key-value databases.

All UUID columns, i.e. primary key columns containing the UUIDs, SHOULD be highlighted differently from the period start and period end columns and other primary key columns.

The database tables SHOULD be marked depending on the role and number of UUID columns:

Any other columns MAY be acceptable depending on the database modeling method such as Anchor modeling, Data vault modeling or Star schema.

The database tables MAY be marked unsafe if they contain no UUID column as primary key or as part of primary key. It means that database integrity and/or flexibility are not protected by proper keys.

kyzer-davis commented 2 years ago

The database tables SHOULD be marked unsafe if they do not contain UUID as primary key or as part of primary key.

I am not sure this is up to the spec to decide.

sergeyprokhorenko commented 2 years ago

You probably haven't seen chaos in databases with compound business keys. Often, incomplete compound keys are used for relationships between tables, hoping for luck. Such databases are definitely unsafe. UUIDs are designed to displace compound business keys. This is exactly the subject of this specification

ben221199 commented 2 years ago

I don't see the need for it. By convention, everbody already uses id as column name and makes it the primary key. For id, somebody can decide to use UUIDs if they want, because it is in the name: UUID.

broofa commented 2 years ago

UUIDs are designed to displace compound business keys

UUIDs are designed to provide IDs that satisfy certain key criteria. The extent to which such criteria make them preferable over existing solutions is going to be application dependent, and highly subjective (and also changeable over time.)

We should limit opining on best practices and conventions to those issues that affect how well UUIDs meet the stated goals of the spec (uniqueness, monotonicity, db locality). Attempting to reach beyond that just compromises how seriously this spec will be taken.

sergeyprokhorenko commented 2 years ago

UUIDs are designed to displace compound business keys

UUIDs are designed to provide IDs that satisfy certain key criteria. To the extent such criteria make them preferable to existing solutions is going to be application dependent, and highly subjective (and also changeable over time.)

We should limit opining on best practices and conventions to those issues that affect how well UUIDs meet the stated goals of the spec (uniqueness, monotonicity, db locality). Attempting to reach beyond that just compromises how seriously this spec will be taken.

You arbitrarily put forward the list of goals and demand that other people be limited by them. It is necessary to rely not on non-existent best practices, but on the analysis of real problems that UUID solves.

broofa commented 2 years ago

Also, what does it mean to mark a database table as "unsafe"? Google doesn't have much to say on the subject, other than MSSQL's TRUSTWORTHY database attribute.

sergeyprokhorenko commented 2 years ago

Also, what does it mean to mark a database table as "unsafe"? Google doesn't have much to say on the subject, other than MSSQL's TRUSTWORTHY database attribute.

Unsafe mark of table means that database integrity and flexibility are not protected by proper keys. It is similar to package unsafe in Golang that violate type safety. On the contrary the MSSQL's TRUSTWORTHY database attribute is about security, not safety.

sergeyprokhorenko commented 2 years ago

The database tables SHOULD be marked unsafe if they do not contain UUID as primary key or as part of primary key.

I am not sure this is up to the spec to decide.

I changed SHOULD for MAY