![]() | |
#11
| |||
| |||
|
|
My point is MS is attempting to make application development easier at the expense of database technology. There is nothing in LINQ that advances db technology one inch. It is pure utility. There is nothing I've read concerning LINQ that indicates that anyone remotely connected with it has any idea of relational ideas/technology. And why should they, it was not a requirement for the job. Had they the brains to understand that relational technology is the key to overcoming the impedance mismatch and leads to a simplified programming model for application development, they may have taken a completely different approach. Their holy grail is making sql server invisible and what message does that send to the database community? The day that the LINQ group recognizes the idea of a true table type will be the day a new crew comes aboard for database development I hope it's soon because net is a marvalous platform, togood to waste on medicore thinkers. www.beyondsql.blogspot.com |
|
Look at the comments, in particular. If the type /could/ be named at design time, at both the database and application layer, then would your Holy Grail have finally been achieved? |
#12
| |||
| |||
|
|
. My objection is not so much to your general idea of variables of type table-with-given-columns (I've recently worked with some systems that could be cleaner if such a thing were available; currently they work around it using temp tables); more to your specific use of D4 in all your examples, as opposed to a pseudo-code extension of SQL. |
|
Quote Then you might want to write examples in a pseudo-syntax that |
|
Unquote |
D4, after all, represents the functional language
#13
| |||
| |||
|
|
To begin with, the idea of a stored procedure returning a 'result' is an sql concept. This concept does not exist in a relational (D4) system. Relationally, a stored procedure only exists when it is created. The execution of a sp, its runtime realization, does not involve the definition of the procedure nor the idea of 'returning' something from it. Relationally at runtime what sql see's as a procedure and a result 'is' a variable of the type of the result. This is the huge difference between the two systems. Relationally the '@ResultSet' and the idea of inserting a query result into it is contradictory and meaningless. The 'name' of the procedure 'is' the variable (table), there is no result from a sp (ie. sql). |
|
The 'output' declaration in the sql sp is based on the general sql idea of 'returning' something. Such a declaration is superfluous relationally as, again. there is no concept of 'returning a something' from a 'this sp'. |
#14
| |||
| |||
|
#15
| ||||||
| ||||||
|
|
In t-sql this should be perfectly clear: DECLARE @X INT SET @X=5 The variable @X can only take one value at any specific time. In a relational system a procedure that returns some value at runtime must behave exactly like @X. |
|
Add to this the idea of type where each result is a different type |
|
This sql sp: CREATE PROCEDURE SqlTwo @A INT OUTPUT, @B INT OUTPUT AS SET @A=5 SET @B=10 DECLARE @C INT,@D INT EXEC SqlTwo @C OUTPUT,@D OUTPUT SELECT @C SELECT @D makes no sense relationally because, again, there are multiple results. Now there are two scalar types (int) returned instead of sql 'resultsets'. Relationally there is no such thing as more than 1 thing (think a variable of a type) at a time. Two scalar results are realized as a 'row' type relationally, ie. 'one' thing. create operator D4Two():row(A:Integer,B:Integer) begin result:=row(5 A,10 B); end; In this case at runtime D4Two is a variable of type row with 2 scalar columns. |
|
From the relational perspective a table/row/list is a variable that behaves exactly like a variable in a programming language. Its value can be assigned to other values just like a t-sql integer variable can. It can be compared to other variables (for equality) just like a t-sql integer variable. It can be passed as an argument to a procedure just like a t-sql integer variable. For these reasons why MS decided to call something a 'table variable' remains a mystery. |
|
Sql distinguishes between user defined functions and procedures. But sql user defined functions are on the same exact level of procedures when looked at from the point of view of 'variables'. Neither one has anything to do with the idea of a relational variable. All this artificial distinction does is serve to make it harder for users to understand the relational model (Why sql choose to create a userdefine function/procedure dichotomy is another topic. But think of 'where' and 'having'). |
|
Rather than center on particular synatax or pseudo-syntax I think it is the ideas that the relational model is based on that is important. And what we're talking about here is just a slice of the relational model. The relational model is not rocket science It's actuallyquiet straightforward. Ironically it's sql that is out in left field. The relational model is in line with all current programming languages. Unfortuneatly thats never been the case with sql This is one of thereasons I find LINQ so unnecessary. Once you get the idea that a big part of the relational model is all about the basic concepts of variables and types I think (I at least hope) that what I've been trying to explain will make perfect sense ![]() |
#16
| |||
| |||
|
|
steve wrote: In t-sql this should be perfectly clear: DECLARE @X INT SET @X=5 The variable @X can only take one value at any specific time. In a relational system a procedure that returns some value at runtime must behave exactly like @X. In general, this is false. For instance, you can't do SET @MyProcedure = (@X, @Y) However, you seem to merely be advocating that a procedure should return exactly one value (which may be a table). Upgrading all the existing procedures that violate this would be a major task, but allowing it as an option for new procedures would be reasonable (if it could be done reasonably efficiently). Add to this the idea of type where each result is a different type In other words, TABLE (X INT, Y INT) is a different variable type from TABLE (M VARCHAR(15), N VARCHAR(15))? This sql sp: CREATE PROCEDURE SqlTwo @A INT OUTPUT, @B INT OUTPUT AS SET @A=5 SET @B=10 DECLARE @C INT,@D INT EXEC SqlTwo @C OUTPUT,@D OUTPUT SELECT @C SELECT @D makes no sense relationally because, again, there are multiple results. Now there are two scalar types (int) returned instead of sql 'resultsets'. Relationally there is no such thing as more than 1 thing (think a variable of a type) at a time. Two scalar results are realized as a 'row' type relationally, ie. 'one' thing. create operator D4Two():row(A:Integer,B:Integer) begin result:=row(5 A,10 B); end; In this case at runtime D4Two is a variable of type row with 2 scalar columns. What if the data you want to return is not multiple scalars, but rather multiple tables? Upon reflection, I suppose tables could be nested in this model, i.e. you can return TABLE(T1 TABLE(X INT, Y INT), T2 TABLE(M VARCHAR(15), N VARCHAR(15))) This would allow bad developers to commit the common 'a,b,c' 1NF violation in a whole new way, but then bad developers can screw things up in any language. From the relational perspective a table/row/list is a variable that behaves exactly like a variable in a programming language. Its value can be assigned to other values just like a t-sql integer variable can. It can be compared to other variables (for equality) just like a t-sql integer variable. It can be passed as an argument to a procedure just like a t-sql integer variable. For these reasons why MS decided to call something a 'table variable' remains a mystery. But you agree that (1) it has some features of variables, and (2) it could reasonably be extended to have more features of variables? Sql distinguishes between user defined functions and procedures. But sql user defined functions are on the same exact level of procedures when looked at from the point of view of 'variables'. Neither one has anything to do with the idea of a relational variable. All this artificial distinction does is serve to make it harder for users to understand the relational model (Why sql choose to create a userdefine function/procedure dichotomy is another topic. But think of 'where' and 'having'). I'd guess these are both for efficiency. They enforce some useful clarity, too (I also prefer FROM X JOIN Y ON X.Z = Y.Z over FROM X, Y WHERE X.Z = Y.Z because table joins are a distinct concept that's worth keeping separate.) Rather than center on particular synatax or pseudo-syntax I think it is the ideas that the relational model is based on that is important. And what we're talking about here is just a slice of the relational model. The relational model is not rocket science It's actuallyquiet straightforward. Ironically it's sql that is out in left field. The relational model is in line with all current programming languages. Unfortuneatly thats never been the case with sql This is one of thereasons I find LINQ so unnecessary. Once you get the idea that a big part of the relational model is all about the basic concepts of variables and types I think (I at least hope) that what I've been trying to explain will make perfect sense ![]() A lot of people find SQL pretty straightforward, especially in this newsgroup. Your choice of (pseudo-)syntax will make a difference to them. (You might get different responses from a newsgroup focusing on front-end programming languages, especially if they already resemble Pascal as D4 seems to do.)- Hide quoted text - - Show quoted text - |
#17
| |||
| |||
|
|
I feel like I'm watching a Greek person and an Italian person discussing the virtues of speaking French :-/ |

#18
| |||
| |||
|
|
On Nov 22, 4:56 am, jhofm... (AT) googlemail (DOT) com wrote: I feel like I'm watching a Greek person and an Italian person discussing the virtues of speaking French :-/ If your a beginner and don't understand something ask questions. If your an expert don't hide your knowledge, share it. I'll give you the benefit of my doubt and won't assume which you are ![]() Assumptions are the mother of all f__kups: 'Under Siege, Dark Territory' www.beyondsql.blogspot.com |


#19
| |||||||
| |||||||
|
|
Add to this the idea of type where each result is a different type In other words, TABLE (X INT, Y INT) is a different variable type from TABLE (M VARCHAR(15), N VARCHAR(15))? |

|
What if the data you want to return is not multiple scalars, but rather multiple tables? Upon reflection, I suppose tables could be nested in this model, i.e. you can return TABLE(T1 TABLE(X INT, Y INT), T2 TABLE(M VARCHAR(15), N VARCHAR(15))) |

|
This would allow bad developers to commit the common 'a,b,c' 1NF violation in a whole new way, but then bad developers can screw things up in any language. |

|
bad developers can screw things up in any language. |

|
'where' and 'having'). I'd guess these are both for efficiency. |

|
But you agree that (1) it has some features of variables, and (2) it could reasonably be extended to have more features of variables? |
They have two choices.
|
A lot of people find SQL pretty straightforward, especially in this newsgroup. Your choice of (pseudo-)syntax will make a difference to them. (You might get different responses from a newsgroup focusing on front-end programming languages, especially if they already resemble Pascal as D4 seems to do.) |
For the rest I'd like to at least see a choice for
#20
| |||
| |||
|
|
Exactly. Think of sql strings. This table, TABLE(TABLE (M VARCHAR(15), N VARCHAR(15)), is a differnt type than TABLE (N VARCHAR(16), N VARCHAR(16))! This means that we couldn't compare the two and undermines real relational division. To declare how many characters in a string is clearly the opposite of what the relational idea of data independence is all about. Relationally there can only be a 'string' type having absolutely nothing to do with its storage characteristics. And this is the same idea in any programming language. This is just one manifestation of how sqls design ignores the concept of a strong type. |
|
This would allow bad developers to commit the common 'a,b,c' 1NF violation in a whole new way, but then bad developers can screw things up in any language. The view that strings like 'a,b,c' violate the idea of the atomicity of a column in an sql table is a direct result of sql's lack of types and lack of relationships between types. There is no violation of any kind in a relational system because the string can be stored as a single value of a column retaining the concept that there individual elements involved. It would simply be stored as a 'list' type. |
|
I don't think MS could lock its developer army in a hotel and tell them to make sql a little more relational They have two choices.Either buy a relational system (like D4) or start from the ground up to develop one. The gulf between a relational system and sql is too great to try to simply make changes in sql server. Which ever major vendor does either will 'own' application development ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |