As explained here, before sql-99 analytic functions a rank was expressed in the form of a subquery: (select aggregate from <foo> where predicate) as rank where Count was generally used as the aggregate and the predicate was an inequality comparison (table2.Y<=table1.Y). As the definition of the rank was refined the predicate became progressively more complex. If duplicate values existed and unique ranks desired then another column had to be used to resolve ties. An expanded predicate could look like: where (table2.Y<table1.Y) OR (table1.Y=table2.Y AND table2.RowID<=table1.RowID) Many experts were so uncomfortable with the nature of computing ranks that they shifted the intent from a rank to a 'line number'. With this slight of hand they were able to argue that it was a 'format' feature and therefore on the conceptual level of 'reporting'. And such things are always done on the client. With the introduction of sql-99 ranking functions and the benefit of clear hindsight the whole issue of how ranks were previously computed revealed itself. Compared to the simplicity and efficiency of ranking functions the sql queries were seen for the odious things they were. What was thought to be 'cleaver' sql was really a query worthy of Dr. Frankenstein. And any calls for removal to the client disappeared. So one would think sql users would have learned an important lesson - the simulation of a construct by a bunch of unrelated constructs is a poor substitute for the real thing. But it seems sqls span of attention is short and history is repeating itself. We can add the idea of simulating a 'list' to the misbegotten ranks. Just as an aggregate and predicate were used for ranks the 'substring' function and a table of numbers are being used to formulate a 'list'. Just like the rank predicate, the substring expression becomes more complex as the nature of the list becomes more refined. There are many examples of list simulation such as here. But all sql list simulations are fundamentally flawed. The principle way for sql to represent something is by a 'table'. So a table is used to represent a list. But a 'table' is a different animal than a 'list'. Sql can logically represent a rank because a rank is a number and sql has a type number. But sql has no type for a list. The same holds for representing a list by any type of string. A string, no matter delimited or non-delimited is not a list. One would think that the function 'substring' would lead to questioning the sql ways to create a list. It is, after all, substring, ie. a function designed explicitly for a 'string'! With a list sql is doomed before it even starts to simulate it. The logical inconsistencies of lists in sql are unfortunately hidden much like ranking functions were hidden. What has filled this vacuum is so much non-sense. It is truly unfortunate that the only thing that can reveal the extent of the logical confusion, not to mention the code mess, is to work with a list type such as in the D4 language of Dataphor.
Dataphor SQL RAC (Relational Application Companion)
A site of hope for those looking for a true relational database system
- a one-one requirement constraint with dataphor (1)
- anatomy of sql server part I - what is a stored procedure (1)
- anatomy of sql server part II - the unit test as part of the database (1)
- anatomy of sql server part III - what does deferred name resolution really mean (1)
- censoring sql posts (1)
- creating an opposite constraint in dataphor (1)
- dataphor (2)
- Dataphor (7)
- dataphor # 13 a table as a parameter (1)
- dataphor - download and start working with it (1)
- dataphor - fixed sized word segments (1)
- dataphor # 10 sql mythology (1)
- dataphor # 11 string differences (1)
- dataphor # 12 trimming a string (1)
- dataphor # 14 sql the meaning of Update..From (1)
- dataphor # 15 views with substance (1)
- dataphor # 16 inclusive vs exclusive solutions (1)
- dataphor # 17 a visual look at ranking queries (1)
- dataphor # 18 data scrubbing using lists (1)
- dataphor # 19 create intervals over strings (1)
- dataphor # 20 browsing an sql window (1)
- dataphor # 21 an example of relational division (1)
- dataphor # 22 reusable procedures (1)
- dataphor # 23 repley to Michel (1)
- dataphor # 24 basics of the table type (1)
- dataphor # 25 extending the dense rank function (1)
- dataphor # 26 query a hierarchy with explode (1)
- dataphor # 27 combine strings with Split and Concat (1)
- dataphor # 28 constants and variables or sql and D4 (1)
- dataphor # 29 another example of relational division (1)
- dataphor #1 introduction (1)
- dataphor #2 splitting strings (1)
- dataphor #3 string concatenation (1)
- dataphor #4 comment (1)
- dataphor #5 comment (1)
- dataphor #6 formal definition (1)
- dataphor #7 sql: table this (1)
- dataphor #8 list to table (1)
- dataphor #9 table constraints (1)
- dataphor creating lists in a query (1)
- extracting numbers from a string with dataphor (1)
- jeff modens dynamic crosstabs for sql server (1)
- linq to sql the what and why (1)
- linq to sql as a window of opportunity to sql users (1)
- linq to sql should be important to sql users (1)
- linq to sql vs. older 4GL attempts (1)
- listing missing table item (1)
- Multiple cascade paths to the same table (1)
- RAC (4)
- RAC #1 comment (1)
- RAC #2 example (1)
- RAC #3 finding the Nth number in a string (1)
- RAC #4 Sql Server 2005 ranking functions vs. Rac ranking (1)
- sorting a delimited string by its numerical string parts (1)
- sql an example of extreme implicit conversions (1)
- sql can't handle complicated cascading updates (1)
- sql CTE should be a variable not a value (1)
- sql dense rank for identifying consecutive runs (1)
- sql is there really a table variable (1)
- sql ranking functions explained by relational types (1)
- sql server triggers are best set based (1)
- sql the idea of using substring to simulate lists (1)
- sql the undefined trigger in Sql Server (1)
- sql vs relational on tables (1)
- sql what the sql CTE covers up (1)
- types and procedures (1)
Monday, July 02, 2007
Sql - History repeats itself simulating lists
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment