Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m probably alone in this, but I dislike naming tables in plural.

IMO, reading “SELECT employee.first_name” makes much more sense than “SELECT staff.first_name”.



Back In The Day at uni in the early 2000s, we were taught that table names should always be singular, and that's mostly what I've seen in the real world since.

I also think the advice around join table naming is a bit silly. Calling a join table between `cars` and `mechanics` `services` (rather than `cars_mechanics`) does not make the relationship clearer, and only works when the relationships maps to a the real world where the relationship has a commonly used name.

The more I read of this guide, the uglier the SQL is.


You can always alias to a singular … like

join users as user on user….

Then do as you please without the that if you are dealing with a user or leave it plural if multiple…

And if we’re talking personal preference I really dislike caps in reserved words in sql, even before highlighting was everywhere it still just feels archaic for no good reason


You are not alone at all, I also prefer singular names for the same reason. I reserve plural names for the rare cases where the single row of a table actually contains information about more than one item, which is usually when I'm doing something denormalized or non-relational e.g. CREATE TABLE user_settings ( user_id INT, settings_data JSON)


You left out the where.

SELECT employee.name where role = 'developer'

Vs

SELECT staff.name” where role = 'developer'

Then the plural one reads better


I don't think it does, because `role` is an attribute of an employee.

   SELECT employee.Name
   FROM employee
   WHERE employee.Role = 'developer' 

reads much better to me than

   SELECT employees.Name
   FROM employees
   WHERE employees.Role = 'developer'


According to the guide it would be e.first_name or s.first_name.


Yes, you are indeed alone in this




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: