5 ms·
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_nam
by hcarvalhoalves 2y ago
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”.
- hackernewds 2y agoYes, you are indeed alone in this
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- ammojamo 2y agoYou 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)
- other_herbert 2y agoYou 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
- croes 2y agoAccording to the guide it would be e.first_name or s.first_name.
- mnsc 2y agoYou left out the where. SELECT employee.name where role = 'developer' Vs SELECT staff.name” where role = 'developer' Then the plural one reads better
- turbojet1321 2y agoI 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'
- turbojet1321 2y agoBack 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.
- deleted 2y ago[deleted]