Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider whether to allow unique constraints on the empty set of columns #2080

Open
kazimuth opened this issue Dec 30, 2024 · 1 comment
Open

Comments

@kazimuth
Copy link
Contributor

kazimuth commented Dec 30, 2024

In database dependency theory, it is legal to have a unique constraint (a kind of functional dependency) on the empty set of columns.

This is equivalent to having a unique constraint on a column of type (). A table can store at most one value of type (), so a table with such a constraint can store at most one column.

This is actually a very useful feature: it lets you have "global state" tables with only one row. But this could be considered an antipattern. We should decide whether or not to support it.

If we do want to support it, this may require some extra work. Our unique constraints are implemented with indexes, and I'm not sure if we support indexing on no columns. But this would be a backwards-compatible change.

@Centril
Copy link
Contributor

Centril commented Jan 3, 2025

Our unique constraints are implemented with indexes, and I'm not sure if we support indexing on no columns.

Currently, we do not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants