3 ms·
Great tip, minor point, did you mean 'returns setof fruits'? Otherwise your function will only return one row. Opinions vary but i think its another good argum
by michelpp 8y ago
Great tip, minor point, did you mean 'returns setof fruits'? Otherwise your function will only return one row. Opinions vary but i think its another good argument for singular named tables as well: 'returns fruit' and 'returns setof fruit' reads better to my eyes.
- combatentropy 8y agoSorry, why yes, you're right! create function get_fruits_in_season(season text) returns setof fruits as 'select * from fruits where season = $1' language sql;
- CuriouslyC 8y agoJust to emphasize the parent's point about singular vs plural, there are a lot of reasons to go with singular: * Singular is much friendlier to find/replace, due to the inconsistency of pluralization. * A good practice is to name association tables by concatenation of the tables being associated (when the association doesn't correspond to a previously named entity). teacher_class is a much better name than teachers_classes, and definitely avoid teacher_classes. * As you move up the stack, structs, interfaces and classes have strong singular conventions. If you spend much time at higher levels, the habits you develop can lead to little bugs when working deeper in the stack.
- deleted 8y ago[deleted]