Earlier quoted context omitted.
> Similarly using Person.PersonID instead of Person.ID gives consistency in diagrams and foreign key naming. I assume you mean you just use PersonID as the foreign key. This oftentimes introduces ambiguity into what the relationship actually is. I prefer names that describe the actual relationship (e.g. author, owner, approver, etc) rather than letting other people guess what it is.
I usually want to reserve the noun like "author" as the embedded record after a join. That way "author_id" is always the key and then "author" is the json_agg joined object that embeds the whole record. Otherwise you're actually introducing ambiguity imo.
How I Write SQL, Part 1: Naming Conventions (2014)
61–70 of 85 posts
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#62Re: How I Write SQL, Part 1: Naming Conventions (2014)
#63Earlier quoted context omitted.
> Similarly using Person.PersonID instead of Person.ID gives consistency in diagrams and foreign key naming. I assume you mean you just use PersonID as the foreign key. This oftentimes introduces ambiguity into what the relationship actually is. I prefer names that describe the actual relationship (e.g. author, owner, approver, etc) rather than letting other people guess what it is.
I usually want to reserve the noun like "author" as the embedded record after a join. That way "author_id" is always the key and then "author" is the json_agg joined object that embeds the whole record. Otherwise you're actually introducing ambiguity imo.
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#64As well, fewer keywords are plural, compared to singular, so there's less chance of accidentally using a keyword if you use plurals
Haven't yet seen an "octopus" table in production...
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#65Without a rigorous attempt at justifying each of these rules, I don't find this article particularly useful. For example, can someone link to or provide a formal explanation for why table names should be singular? I actually really wanted to read the full relational algebra rational for that one.
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#66Earlier quoted context omitted.
Don't use an ORM is the answer just put in the effort to lean SQL
That is a weird middlebrow dismissal of a response with essentially no value to anybody. Use an ORM when appropriate; when using one, follow its conventions. Don't use an ORM if it's not appropriate. This is much better advice.
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#67How come I have never in a multi decade career come across "i18n". I though the canonical way of doing this was to write KEYWORDS in caps and use camel case for Variables. Also never really brought into adding the type as part of a name - your type is already defined in your schema.
Really? I have. In some circles (e.g., the IETF), i18n is an ancient acronym. People who've worked on operating systems (e.g., OS X, Solaris, RHEL, whatever) have to deal with L10N (localization). G11N (globalization) is I18N + L10N. And then there's a11y: accessibility. This is all about making user interfaces accessible for people with low or no vision, low or no hearing, difficulty typing, and so on. There are gen…
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#68Earlier quoted context omitted.
Don't use an ORM is the answer just put in the effort to lean SQL
This injunction doesn't really scale across a team. I've spent weeks of my life tuning SQL, to the point of writing SQL generation libraries to effectively override the database optimizer when it consistently makes poor decisions in specific use cases. But I don't expect the rest of the team to know SQL as well as I do. When I'm writing or generating SQL, I don't really care much what the naming convention is. If it'…
maybe we should have a fizbuzz for SQL as a filter :-(
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#69The other devs' eyes glaze over when I say things like 'stored procedures' and 'trigger functions.' Bah.
Re: How I Write SQL, Part 1: Naming Conventions (2014)
#70Joe Celko, as well as ISO-11179, tell us to use collective names ("personnel") or plural names ("employees") for tables As well, fewer keywords are plural, compared to singular, so there's less chance of accidentally using a keyword if you use plurals Haven't yet seen an "octopus" table in production...
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d5f2f...
> Yes, this is the same version as I found, but the closest thing I could find to addressing table names in the paper itself was an "Object Class name", something like an OOP Class or something you'd find in a UML diagram, but not really the same as a table name, and in any case all the examples were singular.
> Was actually kinda hoping Celko would deign to comment on this himself as he seems to be the chief proponent of the "collective identifiers as specified by ISO 11179" meme.