TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SQL style guide – a consistent code guide ensuring legible and maintainable code

16 pointsby Treffynnonalmost 10 years ago

3 comments

alexatkeplaralmost 10 years ago
&quot;Use a collective name or, less ideally, a plural form. For example (in order of preference) staff and employees.&quot;<p>I hope Simon Holywell has never had to model a zoo in SQL. &quot;Where are the rattlesnakes Simon - are they in the rhumba, crash or knot table?&quot; [1]<p>[1] <a href="http:&#x2F;&#x2F;blog.writeathome.com&#x2F;index.php&#x2F;2013&#x2F;03&#x2F;improved-animal-groups-poster&#x2F;" rel="nofollow">http:&#x2F;&#x2F;blog.writeathome.com&#x2F;index.php&#x2F;2013&#x2F;03&#x2F;improved-anima...</a>
评论 #9943005 未加载
HCIdivision17almost 10 years ago
What&#x27;s the stance on using tabs to keep the stuff after keywords lined up? Whacking space a bunch of times to keep an OR lined in a WHERE clause is incredibly annoying. Why not just go WHERE\tcol1 = 3\n\t\tORcol2=6<p><pre><code> select * from asdf where col1 = 5 or col2 = 6 </code></pre> I&#x27;ll concede that the river is less pretty, but it&#x27;s substantially easier to type, and SQL keywords are remarkably conducive to being tabbed around.<p>EDIT: Perhaps hilariously, by preceding the code with two spaces, the stuff got out of alignment. I&#x27;m adding another two padding spaces to start. (I usually use a 4 space tab, but I can see how the river becomes a bit wide on 8.)
jmnicolasalmost 10 years ago
&quot;Use a collective name or, less ideally, a plural form. For example (in order of preference) staff and employees.&quot;<p>This goes contrary to what I was taught : use singular form. When I model my databases I think in those terms : employee works for 1 to n company, company has 0 to n employee. Since it&#x27;s a &quot;many to many&quot; relationship you need a third table (entity really) which you could call &quot;working_with&quot;. The columns are id_employee and id_company.<p>This is the basis of the Merise method, but I don&#x27;t think it&#x27;s available in English. It makes modeling databases really easy.
评论 #9941514 未加载
评论 #9943121 未加载
评论 #9941406 未加载