-
Notifications
You must be signed in to change notification settings - Fork 9
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
Foreign Key Usage Design Spec #12
Conversation
…c-foreign-key-usage # Conflicts: # design/specs/foreign-key-constraints.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good overall. Added some comments with further thoughts.
Nice work! I've a few quick notes. These may have been addressed already. Additional options and defaultsPostgres provides some options for FKs, like what to do when a referenced column is deleted or updated, or whether to even allow that ( For the sake of development speed we might just want to use a sensible default at the moment. If so, it might be nice to tell the user what that default is. I think defaults were discussed at some point and we arrived at TerminologySQL community's terms around FK are pretty confusing and not well established (I've seen referencing, referred, source, target, columns, etc.). When you're looking at a different SQL library or a different documentation, chances are that it will be calling these properties something new. Concern here is that when the user will be looking at the create/edit FK constraint dialog it might be taxing for him to understand what do the terms referenced table, reference column, column (no prefix) mean. I'd say there isn't an easy solution for this: we either make it verbose or short but confusing. I'm leaning towards verbosity: referred table/column and referring table/column. Referred/referring being popular abbreviations for referenced/referencing. Also, in the context of FKs, saying column or table without specifying whether we're talking about the referred or referring column/table is somewhat ambiguous. There's a colloquial convention that when you're ambiguous you mean the referring object, but it might take a user some extra time to realise that. Something to think about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghislaineguerin This looks really good and detailed. I had a couple comments.
@ghislaineguerin I updated the status of this PR to review and added everyone to the assignee list. @dmos62 @mathemancer @pavish @seancolsen @silentninja Please unassign yourselves once you've reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from one clarifying question, this looks great!
- If the table contains no records, the user sees an option to add a record. | ||
- If there aren't any matches, the user sees an option to add a record for the newly entered value or try changing the 'Search Columns' table preference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens after the user clicks "Add Record" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seancolsen we haven't defined that part of the flow yet. I assume we'll know more when we work on views as it also involves the creation of new records in other tables. I'll add a note for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the "Add Record" option from the spec, we can add it in once we have it defined. It'll confuse implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall.
Small comment: I noticed in the video for Scenario 2 that we "remove" the foreign key constraint from some parts of the UI, but we "delete" the foreign key constraint from others. I think these should be unified to one specific word/concept to avoid confusion, and that word/concept should be chosen carefully. We want to make sure the User understands they're not deleting any data when they take the action, but only the attachment between the tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghislaineguerin This looks great overall. Some (hopefully) minor comments.
#### 2. The user selects a table from the list of available tables | ||
- The user selects the table on the 'one side of the 'one-to-many' relationship. | ||
- The user is not familiar with the concept of foreign keys. | ||
- The user has created tables within Mathesar, where the ID column is automatically generated and sent as the primary key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good assumption to make. We should handle cases for all tables, even without primary keys.
We can solve this for the first version by not supporting creating links through scenario 1a. Perhaps we could have a little help message that says "Why don't I see all my tables in this list?" and explain that we only show tables with primary keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if we show all the tables, but disable the table without a primary key with a text hint that conveys the message that the primary key is missing, this could be extended to directing them to create a primary key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @silentninja. I think it would be best to show the tables and prevent selection. I will add details for this in the spec.
- If the table contains no records, the user sees an option to add a record. | ||
- If there aren't any matches, the user sees an option to add a record for the newly entered value or try changing the 'Search Columns' table preference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the "Add Record" option from the spec, we can add it in once we have it defined. It'll confuse implementation.
|
||
### Linked Records for Multi-Column Foreign Key Constraints | ||
|
||
- The current UI does not consider multi-column foreign key constraints and how those would be retrieved and selected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should define this a bit, even if only to say that we treat it like a text column for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kgodey I've added additional information.
|
||
### Usage of Color | ||
|
||
- A suggestion to use color as a means to differentiate table references has been included in this spec. However, there are implementation details that need to be discussed before the team can make a decision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decision about what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kgodey I've updated to add more detail.
- The user opens the column menu for a column that has a foreign key constraint applied | ||
- The user clicks on the preferences link | ||
|
||
## Components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the constraints modal component?
@ghislaineguerin Please re-assign me when the spec is ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghislaineguerin Looks good overall, a couple of minor changes requested.
|
||
### Terminology | ||
|
||
- `Remove` and `Delete` are used throughout this spec and should be applied consistently across the entire user interface as they are different affordances. `Remove` will be used for data that can be added back, while `Delete` will indicate data destruction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually decided to use Delete for everything in mathesar-foundation/mathesar#872
#### 2. The user selects a table from the list of available tables | ||
- The user selects the table on the 'one side of the 'one-to-many' relationship. | ||
- The user is not familiar with the concept of foreign keys. | ||
- The user has at least two tables with primary key constraints set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need one table - the one that's being linked to. And it should be a single primary key and not a composite primary key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I've updated the assumptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghislaineguerin I noticed a typo, made a suggested fix along with a clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than my one suggested change.
Co-authored-by: Kriti Godey <kriti@kritigodey.com>
This PR contains the specs needed to implement the design for Usage of Foreign Key Contraints