<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - Thinking in Sets - Comments</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets</link>
 <description>Comments for &quot;Thinking in Sets&quot;</description>
 <language>en</language>
<item>
 <title>If only I had found this months ago ...</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-1423</link>
 <description>&lt;p&gt;I recently had the opportunity of turning a huge VB payroll processing batch job into a set of SQL Server stored procedures. Whilst it took a long time to work out, the use of sets to do the processing resulted in a MUCH faster batch job (&amp;gt;90% of time was saved). However a young .Net programmer wandered onto the team some months later and had great difficulty understandin why we hadn&#039;t just moved to VB.Net as he understood it to be MUCH faster at this sort of processing.&lt;/p&gt;
&lt;p&gt;If we had stuck to a set of loops he would have been quite right, but because we changed the code to process sets of data at a time it resulted in a batch job that as it got larger got &lt;i&gt;faster&lt;/i&gt; per employee record because the processing time was based on the set not the individual records.&lt;/p&gt;
&lt;p&gt;Anyway, I wished I&#039;d found this article back then, it sure would have helped explain it to him!&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br /&gt;
Angus&lt;/p&gt;
</description>
 <pubDate>Mon, 21 Aug 2006 18:32:15 -0700</pubDate>
 <dc:creator>Angus McDonald</dc:creator>
 <guid isPermaLink="false">comment 1423 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Code v Sets</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-332</link>
 <description>&lt;p&gt;&quot;Code&quot; and &quot;sets&quot; are both forms of WRITING. But at the top of most organizations, the ideal is that the CEO shall SPEAK, like Pharaoh, saying &quot;let it be written: let it be done&quot;.&lt;/p&gt;
&lt;p&gt;Invisible scribes shall write down what old Pharaoh says and other guys shall do the task.&lt;/p&gt;
&lt;p&gt;Now, suppose one of the scribes says, based on his knowledge of code and sets, &quot;Pharoah, sir, what you have said is BS because it is a null set&quot;.&lt;/p&gt;
&lt;p&gt;Do you suppose that old Pharoah will say, &quot;oh, sorry, Hank?&quot;&lt;/p&gt;
&lt;p&gt;No, Hank-the-scribe is dragged away from his workstation and set to making bricks with straw with the Children of Israel.&lt;/p&gt;
&lt;p&gt;Speech is thought more trustworthy than writing, and Hank may have entered the query wrong.&lt;/p&gt;
&lt;p&gt;Which is to say that while conservatism locates the problem of bureaucracy in the lower levels, where self-interested scribes create unauthorized systems, the problem may be that the high concentration of the written leads to a regression at the top, in Air Force One, where undocumented decisions are taken in a way that depends upon, but denies, the material basis in writing.&lt;/p&gt;
&lt;p&gt;Heinlein thought the world of Starship Troopers would be controlled by &quot;Symbolic Logic&quot; but he also saw that it would need a warrior caste with oral traditions. But what is invisible to him is that if you specialize and select a caste you are creating the invisible Guardians at the top, and the irrationality of the whole (which Orwell presents in 1984).&lt;/p&gt;
&lt;p&gt;The irrationality of the whole creates MIS cynicism. My uncle worked hard for many years at the IRS but told me some real horror stories about their continual vain attempts to get tax systems under control...much less modernized.&lt;/p&gt;
&lt;p&gt;This is common knowledge. But what&#039;s invisible is that the whole can be rational if it has a humanistic orientation. Note that in all the talk about how &quot;Social Security is in trouble&quot; one doesn&#039;t hear anything about their data systems for in fact since 1935 their data systems have worked effectively...perhaps ultimately because what&#039;s not to dislike about some old person not having to live on Puppy Chow.&lt;/p&gt;
&lt;p&gt;Whereas the IRS and its data systems have to confront Negation from day one where Negation is the permission given in the Ninth Amendment for Americans to pay as little tax as humanly possible.&lt;/p&gt;
&lt;p&gt;[In China my wages are withheld. When I asked about filing a return, I had to explain what a return is. It seems that if you pay too much here in withholding, you should be honored to have so contributed to the historic struggle of the people&#039;s Leninist state. OK, OK, I am honored.]&lt;/p&gt;
&lt;p&gt;[Seriously, during the 1970s I consistently overpaid income taxes to the US because I didn&#039;t want to be bothered and figured it was in a good cause.]&lt;/p&gt;
&lt;p&gt;I agree that the set is a powerful concept. But note that set theory has its own paradoxes:&lt;/p&gt;
&lt;p&gt;SELECT * FROM tableOfAllSets WHERE Not isAmemberOfItself&lt;/p&gt;
&lt;p&gt;Also, note that even in constructing SQL you have to use various rules of thumb such as not using * for the field list and NOT sending the query from a client over and over again.&lt;/p&gt;
&lt;p&gt;Even if you resolve to program in pure logic you are still embedded, in Heidegger&#039;s sense, in the real world.&lt;/p&gt;
&lt;p&gt;&quot;Oh, I see your problem, Mr. President. You have sent the query from your Visual Basic program to the server and when you ran it against the live census data base you hosed everything.&quot;&lt;/p&gt;
&lt;p&gt;[The frightening idea of a President using Visual Basic is not complete science fiction, for Brian Kernighan, now a Princeton professor, uses Visual Basic in his nonmajor computer science classes to teach the best and brightest, he hopes, that programming is not for bozos.]&lt;/p&gt;
&lt;p&gt;Data systems remain material and embedded in the real world, in a way that Lerry Lessig shows in Code and the Laws of Cyberspace.&lt;/p&gt;
&lt;p&gt;Which means that their study has to start with the &lt;a href=&quot;http://en.wikipedia.org/wiki/Normative&quot;&gt;normative&lt;/a&gt; and not the descriptive. In day one of computer science, it should be announced that computer science is not about getting rich but about the just apportionment of resources using technology.&lt;/p&gt;
&lt;p&gt;In other words, I would generalize, somewhat, Bjarne Stroustrup&#039;s combined normative and descriptive discussion of C++, in which he describes C++ in parallel with best practice.&lt;/p&gt;
</description>
 <pubDate>Thu, 14 Apr 2005 18:18:31 -0700</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 332 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>The what and not the how</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-331</link>
 <description>&lt;p&gt;Data base authority C. J. Date, in a book entitled &quot;The What and not the How&quot; reminds us that his original motivation with SQL and the relational model was to replace &quot;epistemology&quot; (what and how we know) with &quot;ontology&quot; (what is).&lt;/p&gt;
&lt;p&gt;The opposition between &lt;a href=&quot;http://en.wikipedia.org/wiki/Epistemology&quot;&gt;epistemology&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Ontology&quot;&gt;ontology&lt;/a&gt; is my own. But it may capture the fact that &quot;programming&quot; is the procedural construction of an epistemological path to knowledge whereas nonprocedural SQL declares ontologically that this is the SET which we want.&lt;/p&gt;
&lt;p&gt;The trouble is that nearly all SQL environments are incapable of making anything but the most primitive inferences about things like data types.&lt;/p&gt;
&lt;p&gt;C. J. Date&#039;s original vision was, I think, that highlevel administrators would &quot;tell the computer what they want&quot; in a purified language. &lt;/p&gt;
&lt;p&gt;I will merely leave the reader with the image of the current President doing this.&lt;/p&gt;
&lt;p&gt;But, you say, the formation of the SQL query is a clerical activity: the Prez merely says to the data base administrator, CJ-Boy, y&#039;all tell me how many terrorist suspects is a-taking flying lessons:&lt;/p&gt;
&lt;p&gt;SELECT name,address FROM terroristDB WHERE isASuspect AND takingFlyingLessons&lt;/p&gt;
&lt;p&gt;Needless to say, any data base admin worth his salt knows that there are any number of ways of forming the query and designing the data base, so the President&#039;s problem becomes not engagement with the world outside the Oval Office, it becomes the self-reflexive task of managing the bureaucracy.&lt;/p&gt;
&lt;p&gt;Harry Truman was perhaps the first President to realize that FDR&#039;s New Deal had created a bureaucracy which he had to manage as part of his job, and, an explanation of the numerous disasters of the Bush administration is that the bureaucracy is out of control. A strong individual like Clinton could control it but it appears that Bush has been highjacked by unprincipled players and the complexity of the apparatus.&lt;/p&gt;
&lt;p&gt;This goes right down to the misuse of Powerpoint (or systems like Powerpoint) and SQL (even including &quot;advanced&quot;, proprietary, classified and hardened versions of SQL running at &quot;full military power&quot;) the mastery of which in a bureaucracy necessarily includes the ability to tell the boss what she wants to hear.&lt;/p&gt;
&lt;p&gt;SELECT peace,justice FROM theEntireMess WHERE NOT aChildIsLeftBehind?&lt;/p&gt;
&lt;p&gt;Yeah, right: but MIS cynicism based on engagement is part of the problem.&lt;/p&gt;
&lt;p&gt;Build Your Own .Net State Department?&lt;/p&gt;
&lt;p&gt;Well, in March 2003, while writing my book, I contacted Geoffrey Robertson (QC), an international lawyer and asked him if my peace group could use international law to stop the war in Iraq. But the technology of spinmeistering, precisely because it embeds the Internet, outpaces the Internet just enough.&lt;/p&gt;
&lt;p&gt;Furthermore Microsoft&#039;s CEO supports the war which makes .Net sort of the dark side.&lt;/p&gt;
&lt;p&gt;But the PROBLEM is thinking in Star Wars terms. Star Wars romanticises the problem.&lt;/p&gt;
&lt;p&gt;Take a look at more declarative languages like &lt;a href=&quot;http://en.wikipedia.org/wiki/Haskell_programming_language&quot;&gt;Haskell&lt;/a&gt;, for you are most certainly on the right track.&lt;/p&gt;
</description>
 <pubDate>Thu, 14 Apr 2005 17:48:10 -0700</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 331 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Query: Is SQL Code?</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-330</link>
 <description>&lt;p&gt;Thanks for helping to clarify the terms I was failing to use, Dan. The terms &lt;i&gt;procedural&lt;/i&gt; and &lt;i&gt;declarative&lt;/i&gt; would have helped me make my point better. And I think I can agree that all of the &quot;stuff&quot; that makes up an application (save the data) could be considered &quot;code&quot;, and  what I referred to above as code might better be described as procedural code.&lt;/p&gt;
&lt;p&gt;I often forget about the SELECT FROM SELECT approach. I&#039;ve got to remember to use that one. I have often used subselects (i.e., SELECT * FROM myTable WHERE myId NOT IN (SELECT id FROM otherTable), but must admit that I find this construction goofy and suspect that there may be an inefficiency lurking in there somewhere.&lt;/p&gt;
&lt;p&gt;Here&#039;s another good one. Did you know that in T-SQL you can create a function that returns a table? Thus you could end up with SQL like this:&lt;/p&gt;
&lt;p&gt;SELECT * FROM dbo.constructSomeTable() ORDER BY firstName&lt;/p&gt;
&lt;p&gt;You can join and apply a where clause and all that. This is actually a pretty useful feature in certain cases.&lt;/p&gt;
&lt;p&gt;Far be it from me to crack on the hybrid declarative/procedural languages. I used to work as a Progress developer, for goodness sake! And the application that I bragged so much about above was all based on stored procedures and it used logical structures and (gasp!) cursors. In defense of my use of cursors, I&#039;m only cursoring through my 300+ rules and then applying each one to the 300,000 other objects in batch. Thus, I only cursor where it&#039;s least costly.&lt;/p&gt;
&lt;p&gt;The point I wanted to make about cursors is that they are very attractive to procedural coders, but that they are not always the best approach and are often used ineffectively and inefficiently. I believe that the great Celko himself has made this point on occasion.&lt;/p&gt;
</description>
 <pubDate>Thu, 14 Apr 2005 08:57:57 -0700</pubDate>
 <dc:creator>Rob MacGrogan</dc:creator>
 <guid isPermaLink="false">comment 330 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Usefulness Acknowledged</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-329</link>
 <description>&lt;p&gt;If it ever comes to a McConnell-esque professionalization (did I just coin that verb?) of Software Development, I think set mathematics and it&#039;s application to data should be a large part of the core cirriculum.  While I hardly claim to have doctoral-leve understanding of the subject, I do know SQL and I completely agree with the point you make, Rob.&lt;/p&gt;
&lt;p&gt;In particular, nested SQL like you mention with the INSERT SELECT FROM statement can be incredibly powerful compared to &quot;one at a time&quot; procedural methods.&lt;br /&gt;
Similarly, table aliasing using SELECT statements instead of actual tables can do amazing things as an alternate form of subquery, i.e.:&lt;/p&gt;
&lt;div class=&quot;codeblock&quot;&gt;
&lt;pre&gt;SELECT T1.columnA, T1.columnB, T2.*&lt;br /&gt;  FROM table1 T1,&lt;br /&gt;       (SELECT a,b,c&lt;br /&gt;          FROM table2&lt;br /&gt;         WHERE [condition]) T2&lt;br /&gt; WHERE [condition]&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This latter device is something I had not been exposed to very much until my current gig.  &lt;/p&gt;
&lt;p&gt;And while it&#039;s true that a procedural mindset can pollute applications of a hybrid language like T-SQL or PL/SQL, I don&#039;t think you can underestimate the power available in the efficient combination of both approaches.  Often, a single SQL statement can (as you illustrate) save scads of work.  This is particlarly true when the procedural route would involve large amounts of network back-and-forth.&lt;br /&gt;
But on other occasions, the ability to procedurally control SQL is invaluable.  An example of this would be Dynamic SQL constructed inside a stored procedure, or branching logic to determine which of a group of SQL statements to execute.&lt;/p&gt;
</description>
 <pubDate>Thu, 14 Apr 2005 08:38:41 -0700</pubDate>
 <dc:creator>Andy Tegethoff</dc:creator>
 <guid isPermaLink="false">comment 329 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Set-Based Ramblings</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets#comment-324</link>
 <description>&lt;p&gt;Great post, Rob, and I share your fondness for the power of SQL. Like you, I very much enjoy sometimes setting aside my hammer and using a wrench instead. It&#039;s nice to have a full toolbox.&lt;/p&gt;
&lt;p&gt;For the sake of discussion I would, however, like to follow the tangent you resisted in your post. I am not on board with the restriction of the definition of &quot;code&quot; to just procedural code. I&#039;m no computer scientist, but I like to think of languages as falling into at least three groupings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;procedural&lt;/i&gt;, within which I would include machine, structured, OO, and aspect oriented languages (though my limited understanding of AOP might be preventing me from seeing that AOP would not fit under the &quot;procedural&quot; label)&lt;/li&gt;
&lt;li&gt;&lt;i&gt;declarative&lt;/i&gt;, which I would use to label languages such as SQL and XSLT&lt;/li&gt;
&lt;li&gt;&lt;i&gt;hybrid&lt;/i&gt;, including languages such as PL/SQL and T-SQL, which mix the procedural and declarative paradigms (though XSLT and straight SQL do this also, in that both XSL and SQL can call out to functions that contain procedural code)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&#039;m sure some might disagree with my groupings, and I&#039;d love to learn more by discussing it with anyone who cares to. That said, I like having examples of all three of these categories in my toolbox. In particular, the power of SQL to operate very efficiently on sets makes it ideally suited for solving certain classes of problem. I also recently had an epiphany about the usefulness of XSLT in certain situations.&lt;/p&gt;
&lt;p&gt;As for the scope of the definition of &quot;code,&quot; I am happy keeping the definition broad, including all of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;stored procedures&lt;/li&gt;
&lt;li&gt;configuration files&lt;/li&gt;
&lt;li&gt;the metadata associated with specialized tools and middleware like enterprise application integration (EAI) and message queueing&lt;/li&gt;
&lt;li&gt;report writer files, like those used by Crystal Reports or Business Objects&lt;/li&gt;
&lt;li&gt;the *entire* database structure, configuration, and data, which can all be represented as scripts&lt;/li&gt;
&lt;li&gt;and of course the Java, C, COBOL, etc. modules that everyone agrees can be called &quot;code&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The reason I like this broad definition is that it is very useful when thinking in terms of configuration management, change management, and deployment management. And it also goes back to the discussion about the &lt;a href=&quot;/mag/articles/reeves_design_main.html&quot;&gt;Jack Reeves essays&lt;/a&gt; in that all of these things are elements of the final, and only complete, expression of &quot;the design.&quot;&lt;/p&gt;
&lt;p&gt;Finally, I wanted to mention &lt;a href=&quot;http://www.celko.com/&quot;&gt;Joe Celko&lt;/a&gt;, a SQL and database expert, and a favorite author of mine. I&#039;ve followed his &quot;&lt;a href=&quot;http://www.celko.com/articles.htm&quot;&gt;Celko&lt;/a&gt;&quot; column for several years. He has a great book called &lt;i&gt;SQL for Smarties&lt;/i&gt; that I highly recommend, and another called &lt;i&gt;SQL Puzzles &amp;amp; Answers&lt;/i&gt;, that I&#039;ve never read but that looks great. I see that he has a new book out called &lt;a href=&quot;http://www.amazon.com/exec/obidos/redirect?tag=developerdots-20&amp;amp;path=ASIN/1558609202&quot;&gt;&lt;i&gt;Trees and Hierarchies in SQL for Smarties&lt;/i&gt;&lt;/a&gt;, which I&#039;ll have to check out. Several years ago I implemented a tree-based relational/SQL-based solution that was based on (though different than) the &quot;trees in SQL&quot; installments of his &quot;Celko&quot; column.&lt;/p&gt;
&lt;p&gt;Anyway, enough rambling. Time for bed.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Wed, 13 Apr 2005 20:43:41 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 324 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Thinking in Sets</title>
 <link>http://www.developerdotstar.com/community/thinking_in_sets</link>
 <description>&lt;p&gt;Coders think in terms of code. It&#039;s the old saw about the hammer. When that&#039;s the only tool you&#039;ve got, everything starts to look like a nail.&lt;/p&gt;
&lt;p&gt;Coders, of course, have more than one tool at their disposal. We have worlds of tools. But coders do like to code (see Andy&#039;s recent &lt;a href=&quot;/community/node/182&quot;&gt;post&lt;/a&gt; if you don&#039;t believe me). It&#039;s what we like to think we do best.&lt;/p&gt;
&lt;p&gt;Before I get too far along here, let me clarify what I mean by code. I argued for a broad definition of source code in a recent &lt;a href=&quot;/community/node/135#comment-296&quot;&gt;comment&lt;/a&gt;, and I&#039;m not backing away from that really, but maybe clarifying a few terms. Let&#039;s say, for the sake of argument, that code is that which is written in a programming language such as BASIC, C, Java, and the rest. I won&#039;t attempt to define it further. And let&#039;s say that what I called &quot;source code&quot; in that other post might better be called simply &quot;source.&quot; Only three paragraphs into my post and I&#039;ve already gone off on a tangent. Typical. &lt;/p&gt;
&lt;p&gt;The point I want to make here is that coders like to work in familiar territory. Present a coder with a problem and his or her mind will immediately go to work on solving that problem in the software language of his or her preference. For example, if you present me with a problem, I&#039;ll probably start right away with a possible solution using Java and some of my recent favorite technologies, such as Hibernate, SOAP, and maybe JMS. Java is my favorite hammer and I like to use it.&lt;/p&gt;
&lt;p&gt;But many many problems are not best solved by building a mighty computer program, as I recently learned.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/thinking_in_sets&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/thinking_in_sets#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/26">SQL</category>
 <pubDate>Wed, 13 Apr 2005 14:56:18 -0700</pubDate>
 <dc:creator>Rob MacGrogan</dc:creator>
 <guid isPermaLink="false">183 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
