3 ms·
I believe GP is talking about how you refer to this column in another table, where "id" is not an option. In the "widgets" table, you need to refer to either "
by heleninboodler 3y ago
I believe GP is talking about how you refer to this column in another table, where "id" is not an option.
In the "widgets" table, you need to refer to either "the id for the user" or "the id to use in the users table" so both user_id and users_id are perfectly reasonable choices if the other table is called "users".
- bluefirebrand 3y agoThat's fair. I honestly did not think about foreign key column names when I was typing, so thanks for pointing it out. I'm always a fan of making foreign key column names more descriptive than just the table name. Widgets may have a user_id but it probably makes more sense to have an owner_id.
- henriquez 3y agoIt’s still a good practice to refer explicitly to the foreign reference in the column name, so in your example owner_user_id would be preferable to owner_id if the foreign key refers to a record in the user table.