Column Moving Improvements¶
Status: Draft Review status: Draft Theme: Data modeling features
Project owner: Brent
|Product spec, requirements, GitHub issues
|UI and UX
|Backend specs and code
|Frontend specs and code
It came to my attention during RSQLA1 that our column extraction and moving feature isn’t complete, and the current state is sort of dangerous. In fact, I’m concerned the current state is so bad that attempts to use this feature could well lead to justified ragequits from Mathesar entirely. I’ve written some problems up in roughly descending order of priority (IMO).
The column moving operation has the potential for data loss, or at least for jumbling up the link in certain edge cases, e.g., if the foreign key was created outside of Mathesar and is on a text column rather than integer.
The column moving operation is one-way only. Currently, you can only move columns along a foreign key link from the referrer table to the referenced table. E.g., from a remainder table to an extracted table. This asymmetry is not portrayed to the user, and they could easily tinker themselves into an irreversible situation.
Merging tables is not available from the UI. This means you can’t un-extract your columns.
If you extract a foreign key column, you’ll lose the foreign key link. Start with:
Teachers | id | Name | Email | |—:|-----------|----------------| | 1 | Ms. Smith | firstname.lastname@example.org | | 2 | Mr. Jones | email@example.com | | 3 | Mrs. Li | firstname.lastname@example.org |
Suppose The Teacher column references the Teachers table ID, and I want to extract the Subject and Teacher columns from the Roster table to create a new table. Currently, this breaks the foreign key link between the Teacher column and the Teachers table.
If you extract or move some portion of the columns involved in a multi-column constraint (e.g., a unique constraint), the constraint is silently dropped with no warning or error. See the issue.
It’s not possible to extract a non-orderable set of columns, or rather when doing so you end up jumbling up the foreign key links. See the issue.
If you try to extract a column referenced by a foreign key column, we currently throw an error, and fail. See the issue.
If you extract columns from the middle of a table, the new foreign key column is still the last column of the table. See the issue.
We need to start this with a product-level discussion to determine what we want to accomplish with the feature from end to end, and if there’s any subset that we can put out that will at least avoid irreversible column moving operations, and avoid any data loss.
Depending on that discussion, or those discussions, we should then modify the column extraction and moving logic accordingly. This will involve lots of back end work, some design work, and a bit of front end work.
Users will no longer be in danger of corrupting their data or making irreversible data modeling mistakes when using this feature.
- Column extraction and moving is really technical, and it will be difficult to portray to users in an easy-to-understand way, especially when considering things like multicolumn keys and preexisting foreign keys.
I think we’d need one cycle to work through the product considerations and plan an attack, and another cycle to implement.