FK column naming convention

16 views
Skip to first unread message

Sean Colsen

unread,
Aug 18, 2022, 11:47:04 AM8/18/22
to mathesar-...@mathesar.org

What naming strategy would we like to encourage Mathesar users to employ when naming their foreign key columns?

Obviously users can name their columns as they see fit, but there are sometimes contexts in which the product might suggest a column name, for example in the Link Table dialog or the Move Columns dialog.

When “Publications” is referencing “Authors”, how do we want to recommend that users name that FK column? Our Library Schema uses “Author Id”, which I’d argue serves as a form of recommendation by virtue of being exemplified in the demo video.

Many UI elements throughout Mathesar will juxtapose a FK column name with a value from that column. For example, the column in the Table Page, the filter condition for that column, the field within the Record Page, the search input within the Record Selector. And, given our Record Summary design, all of those places will format the value as a string representation of the record – not the PK value of the record.

Specifically for the demo video, I have been concerned that our current naming strategy will appear awkward. Consider:

Author Id: Margaret Atwood

In contrast, the following simplified naming strategy produces a UI which feels more natural, given our Record Summary design.

Author: Margaret Atwood

I’d like to propose the following FK column naming strategy:

  • If singularization is feasible (e.g. in the demo video and other examples/documentation where we have manual control), we use the singularized form of the linked table name (e.g. “Author”).

  • In the application, where singularization is not straightforward, we don’t suggest column names. Instead we require the user to manually name the FK column.

Adopting this proposal would mean:

  • Modifying column names in the Library schema
  • Modifying the logic within the Link Table dialog to stop generating a suggested name. (It currently suggests the name Authors_id.)
  • Modifying the logic specified within the Column Extraction specs to stop generating a suggested name. The suggestion logic is current being debated in PR.


Kriti Godey

unread,
Aug 18, 2022, 11:56:37 AM8/18/22
to Sean Colsen, mathesar-...@mathesar.org
I think everything in this email sounds good except for:

In the application, where singularization is not straightforward, we don’t suggest column names. Instead we require the user to manually name the FK column.

Our general approach to the product has been to provide users with defaults that they can modify (convention over configuration, see our Product Principles). I think we should stick with this approach here, which means we still need an algorithm to generate a suggested name. I think we should instead drop the underscores and any mention of "id" or "ID" from suggested names.

Sean Colsen

unread,
Aug 18, 2022, 12:38:55 PM8/18/22
to Kriti Godey, mathesar-...@mathesar.org
Cool -- I was on the fence about using the table name as-is vs withholding a suggestion, so using the table name as-is seems good.

Kriti Godey

unread,
Aug 18, 2022, 12:42:15 PM8/18/22
to Sean Colsen, mathesar-...@mathesar.org
Could you create tickets for modifying the library schema and updating the algorithm in both places?

Sean Colsen

unread,
Aug 18, 2022, 12:57:17 PM8/18/22
to Kriti Godey, mathesar-...@mathesar.org

Kriti Godey

unread,
Aug 18, 2022, 12:59:44 PM8/18/22
to Sean Colsen, mathesar-...@mathesar.org
Thanks!
Reply all
Reply to author
Forward
0 new messages