tables icon indicating copy to clipboard operation
tables copied to clipboard

UNIQUE constraint on columns

Open mortee opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

I can't specify that a column's values need to be unique. If Tables is to be considered anything like a database, then this would be essential.

Describe the solution you'd like

Just like there's a "required" switch on the column creation dialog (NOT NULL), a "unique" switch should be there too. Row creation should fail if the value is not unique.

Describe alternatives you've considered

No response

Additional context

No response

mortee avatar Nov 09 '23 23:11 mortee

Do you have a special use case in mind?

We don't want to cover all features a db would have, so lets talk about use cases to see if this helpful.

datenangebot avatar Nov 10 '23 07:11 datenangebot

My case at hand involves storing some information about correspondents based on their email address. I would like Tables to prevent me from inserting the same address twice.

I'm definitely not suggesting covering all DB features here, but I think a UNIQUE requirement on a field is so utterly common across all kinds of table data, that it doesn't even require much justification other than that.

Also, I think it would definitely not be confusing for users, this is a very clear and obvious principle.

Also (just guessing here) implementing it would be close to trivial: the UI would consist of a single additional switch on the column dialog, and a failure condition on creation/update. Also, since it is a primitive feature of any underlying DB, the back-end part would be trivial to implement too.

mortee avatar Nov 10 '23 12:11 mortee

Do you have a special use case in mind?

We don't want to cover all features a db would have, so lets talk about use cases to see if this helpful.

I don't think that this crucial feature https://github.com/nextcloud/tables/issues/172 will not work well without the ability to avoid duplicates.

Another Use Case: Master Data Management ( E.g. a Table for all Member of a Team) Or listing unique items like invoices and avoid having the same invoice number twice,

xbluemonkx avatar Jan 31 '25 19:01 xbluemonkx

If this is implemented, please be aware that there is a copy-feature that might need some adjustments https://github.com/nextcloud/tables/pull/1713

Furthermore this might affect the import feature.

Just posting this to keep in in mind.

xbluemonkx avatar Apr 01 '25 06:04 xbluemonkx