Slashdot Mirror


An Alternative to SQL?

Golygydd Max writes "Dave Voorhis from the University of Derbyshire has developed a program incorporating Tutorial D, a language designed to overcome of the shortcomings of SQL, and developed some years ago by Hugh Darwen and Chris Date. Until now, no-one had done anything with it but Voorhis is hoping for wider adoption; although we think it would be like pushing water uphill though." Update: 10/13 12:43 GMT by T : An anonymous reader writes "It's being picky I know, but the university in question is in fact called The University Of Derby, not Derbyshire."

116 of 505 comments (clear)

  1. Who remembers Knowledgeman? by Pig+Hogger · · Score: 3, Interesting

    Who remembers "Knowledgeman", that database language of 20 years ago which got eclipsed by dBase???

    1. Re:Who remembers Knowledgeman? by Anonymous Coward · · Score: 3, Interesting

      Whoa! That's taking me back! I spent a couple of years during my undergrad ('83-'87) using KMan... it seemed far superior to dBase. No one ever wrote a compiler for it (ala Clipper or QuickSilver for dBase) so it pretty much died a slow death. Too bad.

    2. Re:Who remembers Knowledgeman? by joebok · · Score: 4, Funny

      Good old K-Man! A fellow programmer once said to me, "K-Man is like a retarded daughter - she can't do much, but you love her anyway."

    3. Re:Who remembers Knowledgeman? by jmelchio · · Score: 3, Interesting

      I'm surprised nobody has brought up Progress yet. It's a database with 4GL and its own query language. I always found it a lot easier to work in than SQL although as anything else, it's not perfect. Because of the productivity of the language it has a steady following and there are quite a few people who sell applications (financial, manufacturing) written in Progress.

      --
      close but no sig
    4. Re:Who remembers Knowledgeman? by stephanruby · · Score: 5, Funny
      "And that same programmer probably stays up at night wondering why he's still a virgin."

      I take it logic puzzles were never your strong point.

  2. shortcomings to sql? by Suppafly · · Score: 3, Insightful

    What are the shortcomings to sql? it seems to be able to handle anything you'd need it to do.

    1. Re:shortcomings to sql? by gl4ss · · Score: 3, Insightful

      well.. assembly "seems to handle anything you'd need it to do" so why the need for higher level programming languages?

      probably something along those lines, that it would be easier to do some things and easier to avoid problems.

      --
      world was created 5 seconds before this post as it is.
    2. Re:shortcomings to sql? by lottameez · · Score: 3, Insightful

      SQL sucks. If you need to do anything much beyond a simple query you find yourself buried in the details of that particular db's implementation. (think date handling for example). I don't want, or feel I should need, to be a DBA to get some data out of a data store.

      Joins are a big pain in the butt, and the case statements get so convoluted I feel like I'm writing LISP.

      --
      Yeah? Well I think you're overrated too.
    3. Re:shortcomings to sql? by lub · · Score: 4, Informative

      RTFA:
      -"you ask a database for "all entries where field X is not equal to 47" it won't return any of those where field X is null because instead of saying "Null doesn't equal 47", the value "null" is deemed not to be comparable with any non-null field."
      -"rather arbitrary habit of allowing nested queries in some places but not others, for instance"

    4. Re:shortcomings to sql? by Unordained · · Score: 2, Informative

      Sort of. Some SQL dialects allow for arrays as a datatype, though often without much in the way of good operators. Relational theory allows an attribute (column) to have any domain (type), including complex types like containers (sets, arrays, maps, etc.) ... in theory, yes, you should be able to do this. SQL, however, is another story.

    5. Re:shortcomings to sql? by l810c · · Score: 5, Informative
      One thing I always wondered was if there was a way to make a table that had a different number of columns for each row. For instance, if you wanted to insert ids from another table, but the number of ids each row would need is a variable ranging from zero to god knows what... Can SQL do that in a way that doesn't involve making a huge table with tons of columns or one big structure holding the ids separated by colons?

      Yuck, you would never Want to do that. That's what relationships and foreign keys are for. You wouldn't populate your id's across columns, you put them in a new table, one row each, with an foreign key linking them back to main table.

    6. Re:shortcomings to sql? by Fred+IV · · Score: 4, Insightful

      You only need to learn about null comparisons once, and nulls are extremely valuable when you get into eliminating rows from a result sets based on matches from data in other tables.

      Combining a left outer join with a search condition where a primary key is null from the joined table is a quick and dirty way to scrub records where there's a match in the joined table, and would be impossible without the concept of nulls.

    7. Re:shortcomings to sql? by Gilk180 · · Score: 3, Insightful
      If you think joins suck (I don't personally agree, but that's all just opinion), you should be using some other database model. After "data is stored in a table", joins are THE feature of relational databases.

      Maybe try an object-oriented database (I hear ObjectStore is good), or an associative database (BerkeleyDB), or an XML database (Sleepycat has one).

      Relational databases aren't the only game in town, they are just the most popular and therefore:
      • have had the most development time thrown at the DBMSs
      • have the most developers who are proficient.
    8. Re:shortcomings to sql? by Deorus · · Score: 4, Interesting

      Usually when you need to write queries for big databases, speed is a concern, so the lower the level, the better. I've never seen a GUI which could write SQL queries as well as I do.

      Additionally, a high level interface is unable to undestand where a query can or cannot be optimized, but I can. For example: there are cases where queries have to be run on a regular schedule to update special optimization tables. These optimization tables are then used when user generated query (e.g.: from web input) comes, so that the user doesn't have to wait for the database to complete that subquery which could have ben run sooner. Only low level can give you such a control.

      Small databases can well use high level interfaces, but those aren't the ones driving the standards anyway since the work is already easy for them. User-friendly interfaces such as Access, Query Builder, and crap like that already provide the required high level for the non-techies.

      If anything comes to replace SQL, I think it won't stand standard long enough as vendors will start adding more and more odd extensions, so the story will probably repeat. Personally I don't care much about the language databases use as long as I feel in control and the general concepts of relational databases remain the same.

    9. Re:shortcomings to sql? by MrLint · · Score: 3, Informative

      Well as for the first part, this is really due to poor design. A null is intended to be used as a special thing. In fact null != null. Its meant to behave like that. This is the reason default values exist. if you want to have a column with empty rows to be 0 and not null then you specify that when you are planning. and when you are counting objects you can have 0. 0 is a value. null isnt a value. There are reasons why nulls are this way. One of which is to look for rows that have no data. If you think dealing with nulls in this sense is hard, imagine trying to programatically deal with what is 'empty' or '0' in an arbitrary column? Is this 0 a numeric? its is a 0x00? is it 0x30?

      Null was meant to take the place of all the hack jobs that were used in older databases to signify non-value, NaN and so on.

      Part of using SQL in the manner that it is, is that you get what you ask for. You dont get what some programmer *thinks* you want. Because at some point you may want something else. I really dont want a computer to guess at what I really want. I want it to tell me what it knows.

    10. Re:shortcomings to sql? by gfody · · Score: 3, Insightful

      comparing assembly language to sql?!
      sql doesn't cut it because it's too high level. trying to do anything somewhat complicated in sql leads to headache and turmoil. the big problem is that there is no lower level interface to communicate to your database server with.. all you can do is hand it sql statements and get your results.

      why bother writing a better sql? how about a low level object based api. use whatever language your client is already written in (so long as its oo). fuck learning another busted ass super high level language.. give me objects, methods, exceptions, etc.

      --

      bite my glorious golden ass.
    11. Re:shortcomings to sql? by subStance · · Score: 2, Interesting

      This sounds more like a job for an XML database than a relational one - tree structures rather than fixed relations would allow you to do that.

      --
      Servlet v2.4 container in a single 161KB jar file ? Try Winstone
    12. Re:shortcomings to sql? by abulafia · · Score: 2, Interesting
      Well as for the first part, this is really due to poor design.

      [...]

      Null was meant to take the place of all the hack jobs that were used in older databases to signify non-value, NaN and so on.

      Yes, and this is a big part of the point of D. The authors assert that the way that current DB structures are designed leads to bad design- that there shouldn't be nulls. They have a lot of good reasons for this belief, and it is true that SQL leads people to rely on nulls in cases is a sort of synergystic nightmare of lazyness.

      (1.08X10^8 Clueless points to the first person who says they don't use nulls, and instead set everything that is be null to ''.)

      The language goes hand in hand with designing databases differently, without the influence of SQL.

      --
      I forget what 8 was for.
    13. Re:shortcomings to sql? by kfg · · Score: 2, Interesting

      More to the point, RTFM, i.e. Date's book, which explains what the relational calculus is, and thus what relational databases are all about.

      At the very least go over an introductory text on set theory and prepositional logic so that you might at least have a basic understanding of what a database query even is.

      Before that about all that can be said to answer OP's question is that SQL is mathmatically incomplete and incorrect, i.e., it gives the wrong answers.

      It amazes me that people got all worked up over the Pentium rounding error when it wouldn't even effect most people, but businesses are willing to put up with provably far greater flaws in software that affects everyone's data, and with nary a peep of complaint about it.

      KFG

    14. Re:shortcomings to sql? by msuzio · · Score: 3, Informative

      That's the idea, you know. SQL is a declarative language, not procedural. You tell the database engine what you want, not how to get it. The idea is that then the query analyzer figures out the most efficient how.

    15. Re:shortcomings to sql? by TheMiller · · Score: 4, Interesting

      It would be perfectly possible in a relationally complete language that includes a relational MINUS operator, without NULLs entering into it at all. And Tutorial D, on which the object of this article is based, does of course include such an operator. Whether NULLs are desirable or not is a matter of ongoing raging debate. I've found them easy to avoid, and queries of all sorts easy to understand without them.

    16. Re:shortcomings to sql? by rycamor · · Score: 4, Informative

      Read "The Askew Wall" and other documents by Hugh Darwen at www.thethirdmanifesto.com for some really good brief descriptions of some of the many logical inconsistencies with SQL.

      Really, 95% of the problems that Chris Date and Hugh Darwen have with SQL revolve around an incomplete relational treatment of data. For example, by definition, a relation cannot have duplicate tuples (rows), but a table in SQL *can*. Also, columns in a table should not have a left-to-right ordering, which they do have in SQL (they should be thought of only as attributes, not positionally). Also, SQL fails to completely implement closure, where the result of *any* relational expression becomes a relation which can be in itself modified by any other relational expression. Also, SQL fails to provide a truly extensible approach to user-defined datatypes or domains.

      Etc... etc... there are many other small kvetches and some big ones with SQL. Read the Darwen docs, and you will see some interesting things.

      Essentially, the problem comes down to an ad-hoc experimental language (SQL), which was only intended as a temporary solution, which was then taken over and re-designed by a committee (ANSI).

    17. Re:shortcomings to sql? by dracocat · · Score: 2

      I guess you would be very disapointed to know that probably most of the queries that you write are rewritten by your database to be optimized whether you optimize them by hand or not.

      You would be surprised at how much your database knows about itself, and what it is able to do with that information in optimizing your queries.

      But then I am sure you know all this better than me, since you sound like the DBA here, and I just rely on highler level stuff.

  3. Lotus Domino... by Kenja · · Score: 4, Insightful

    Try using Lotus Domino for a week. You'll be begging to go back to SQL.

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
  4. What's the use? by generalpf · · Score: 4, Insightful

    Is there anything that SQL can't do? I've been using various RDBMS for years and it hasn't come up yet.

    1. Re:What's the use? by treat · · Score: 5, Insightful
      Is there anything that SQL can't do? I've been using various RDBMS for years and it hasn't come up yet.

      Is the sole issue what it can and can't do? what if there was an easier way to express joins? Most queries I write have more joins than actual query. Even though the database already knows the relationships between the tables.

    2. Re:What's the use? by neurojab · · Score: 5, Interesting

      Have you ever seen a 25 way join or a 30 way UNION? I've seen queries that go past a given RDBMS's 32k query size limitation. Even worse, I've seen the code that GENERATES these horrendous queries. It's like seeing your parents having sex; it changes your life forever.

      Please, please, there must be a sane way to query data from a highly normalized database.

    3. Re:What's the use? by Anonymous Coward · · Score: 3, Insightful
      Have you ever seen a 25 way join or a 30 way UNION?

      Call me crazy, but if you have a 25-way join, don't you think you have bigger problems than your querying language? Maybe the person that is asking for the join needs to change their business processes.

    4. Re:What's the use? by timeOday · · Score: 2, Interesting
      Please, please, there must be a sane way to query data from a highly normalized database.
      Prolog! Logic languages are well suited to relational data, where a table maps to a predicate. The logic programming community spent a couple decades trying to convert everybody from SQL and nobody listened.

      I was about to say SQL is like COBOL, but SQL seems to be even more persistent so perhaps it's not as flawed.

    5. Re:What's the use? by mcrbids · · Score: 2, Interesting

      Even worse, I've seen the code that GENERATES these horrendous queries. It's like seeing your parents having sex; it changes your life forever.

      Amen, I HEAR you, brother!

      I've had to write "dynamically generated" queries - and they are a TOTAL MESS, with lots of crappy if statements and string appends...

      300 lines of code to properly parse a search page response, to generate a 20-line query that executes against 5 tables.

      Ugh.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    6. Re:What's the use? by cdc179 · · Score: 3, Insightful

      It's called created views. This way you just access the view in your code.

      Most people lack the suficient skills to program good DB applications. And they don't find anybody with the DB skills to help on the backend.

      This is where most of the issues come into play. Get a DBA that knows what they are doing.

    7. Re:What's the use? by fupeg · · Score: 2, Informative

      I wouldn't call you crazy, but definitely naive. Welcome to the world of big, legacy systems. Comments like "change your business process" will get you nothing but a pink slip (or worse, a job in QA.) Go read any large company's financial statements sometime. There's a good chance that one of these monster join/unions was used at some point in generating the report that was used for the statement. Chances are also that it was auto-generated by some very expensive ERP software. Now go learn about these things and stop acting like know anything about "business processes."

    8. Re:What's the use? by jacobcaz · · Score: 4, Informative
      • Call me crazy, but if you have a 25-way join, don't you think you have bigger problems than your querying language? Maybe the person that is asking for the join needs to change their business processes.
      Go work in a big ERP system. We use PeopleSoft and one of our tech has been debugging an AP (maybe GL?) query that's not working as expected and it's a 20 union beast. That's delivered too, not some home-rolled query. I'm sure there are worse queries out there lurking in the hearts of our system too.

      As for just changing our business process, well that's fine in an ideal world, but in practical reality it ain't gonna' happen without an act of Congress. You have to have someone who knows "best-practice" methodolgy come up with a new process, get sign-off across multiple departments and our auditing company so our banks and major vendors are okay with the changes, and then begin process training and roll-out. And that's for a small, private company; if you're public and have to add SOX compliance to the mix...well, good luck.

    9. Re:What's the use? by Piquan · · Score: 2, Interesting

      Prolog! Logic languages are well suited to relational data, where a table maps to a predicate. The logic programming community spent a couple decades trying to convert everybody from SQL and nobody listened.

      Funny you should mention that. I'm now working on a program that takes user queries (from a Perl program), converts them to Prolog, and finds the solutions against a SQL database.

      It seems to work great, so far.

  5. SQL has shortcomings...is this news? by Ars-Fartsica · · Score: 2, Insightful

    SQL also has decades of optimizations in reliable code...no one will be dropping their Oracle license over this.

    1. Re:SQL has shortcomings...is this news? by antifoidulus · · Score: 2, Insightful

      You are right, initially anyway. Anyone who can afford an Oracle license will not drop it, but my bet is that it will be picked up by hobbyists. If it's any good, then it will probably make it into small scale, relatively free standing commercial projects(so as not to disrupt anything that you already have built), if it's still good, then it may get adopted.
      Keep in mind, the definition of "good" will vary from group to group. Hobbyists may want something that is interesting to play with, that will allow them to easily to powerful things, whereas commercial users will be more interested in scalability and reliability.
      This is how ideas are supposed to evolve, unfortunately the "bandwagon" mentality grips a lot of our culture, and people will just jump on whatever the bandwagon of the day is(.com, outsourcing etc) with little regard to whether or not it is beneficial for their organization.

    2. Re:SQL has shortcomings...is this news? by kfg · · Score: 4, Informative

      How is SQL "not good enough"?

      Look, I don't mean to be terse, really, but a Slashdot post is not the appropriate place to give a freshman tutorial on database theory, and the very fact that you ask your question means you need one.

      In that light about all I can say is that SQL corrupts data, gives the logically wrong answers to querys and ties the logical model to the physical platform (think of Java and the JVM for an idea of why this might not be a good thing for a cross platform data manipulation system).

      If this answer does not satisfy the solution is simple, read Chris Date's introductory book. He's already written it. I'm not going to duplicate it here. Until you do so you will probably remain ignorant of what a database even is, which, per above, makes it rather hard to explain what's wrong with a particular implimentation (just as it would be hard for me to explain a problem in orbital mechanics to you if you hadn't at least gone through an introductory physics text).

      Of course, you can always go to Fabian Pascal's website ( which Date is a contributor to), but until you read Date's book you're likely to just think of Fabian as some sort of crank, out of ignorance. Until you take the trouble to learn what you need to know to evaluate his arguments you have no real basis for judging him in error.

      Of course, that doesn't stop most people.

      KFG

  6. The shortcomings of SQL by mistersooreams · · Score: 5, Insightful

    I use SQL a lot and I agree that has failings. The clumsiness inherent in, say, nested joins is quite amazing when you consider how important databases are in modern industry. This is a consequence of the "near-English"ness that SQL strives for, but that property is also what causes people to adopt SQL in the first place. We'll probably look back at SQL in five years and laugh... but weren't people saying that five years ago?

    1. Re:The shortcomings of SQL by Unordained · · Score: 3, Insightful

      COBOL was(is) also english-like. People liked it. Then they liked it less. But enough had been written in COBOL that the damn thing just won't die, even if you can do the same thing faster in new languages. Learning a language is trouble, converting old programs is trouble, and you don't want to let people forget old languages for fear nobody will be around to maintain those old, unconverted programs...

      SQL will be around for a while still, because it's "good enough" and "already known" and there are lots of "legacy apps using it" and the new stuff is immature. I have trouble convincing people that transactions are important, that joins really should be done in the server, that they shouldn't create attributes named "value1" and "value2" just because they currently only have two, ... convincing them that the language they use is (to be nice) underkill is just not going to happen.

      Sure, I want a new language, I wouldn't mind learning it, heck, I wouldn't mind writing it. But the problem is convincing enough people that what they have isn't good enough.

    2. Re:The shortcomings of SQL by Unordained · · Score: 3, Insightful

      In the case of the owner of my ISP, there's no firing I can do; besides, I like the guy. And yes, web devs as well ... all about simple selects and then post-processing everything in the script ... after all, it works, right?

      In the hacker world, it's not about pretty/good solutions, it's about making a problem go away quickly so you can move on to the next problem. It's all about writing one-time scripts in whatever language you know, not learning another language unless you're bored or can't solve your problem with what you already know ... It's not the environment I'm in, but it's one I run into now and then. It's hard to give these people better tools because nothing is "good" to them, but everything's "good enough". Sure, a drill would be perfect for this, but I only have a hammer -- but I've made do a thousand times before, and I can do it again, I don't need a drill. These are people who do, in fact, get problems solved. They're terribly useful/valuable -- they would just be more valuable if you could give them tools with which they could do the job even faster; but you have to get past that initial annoyance and even having to look at a new tool -- a new tool to add to their already long list of unix commands, scripts in random directories, knowledge of several languages, etc. Firing such a person doesn't get the job done.

  7. dont think so by Anubis350 · · Score: 5, Insightful

    so to overcome the (not really all that many) shortcomings of sql we will all learn how to use something completely new. Yeah, adoption going to be quik and complete........

    --
    "goodbye and hello, as always" ~Prince Corwin, from Zelazny's Amber series
  8. Heh by FiReaNGeL · · Score: 5, Funny

    The name doesn't help... "Tutorial D" doesn't sound advanced at all...

    Try proposing to your boss to replace your mySQL database with "Tutorial D" for... no good reasons? Will happen. Soon. Right?

    1. Re:Heh by phrenq · · Score: 2, Funny

      I dunno... if your boss bought in to MySQL, then he may be the suggestible type.

    2. Re:Heh by isny · · Score: 2, Funny

      Sounds like something that the government would put together as part of the tax code. "Yeah, I filed my 1040 with a schedule C and Tutorial D."

  9. I gotta say ... by Daniel+Dvorkin · · Score: 5, Insightful

    "SQL is sloppy and unpredictable; Tutorial D is a correct relational database language."

    sounds a lot like

    "C is sloppy and unpredictable; Pascal is a correct programming language."

    --
    The correlation between ignorance of statistics and using "correlation is not causation" as an argument is close to 1.
    1. Re:I gotta say ... by jcr · · Score: 3, Insightful

      Umm... What's your point?

      C is sloppy and unpredictable, mostly due to the fact that it has neither arrays nor strings, but fools people into believing that it does by presenting pointers as if they were arrays. That flaw alone is responsibile for nearly every buffer-overflow crasher or security exploit I've ever seen. Add dangling pointers and C's non-existent memory management, and you've probably accounted for well over 90% of the flaws in C programs.

      If we wrote networking code in Pascal, Ada, FORTRAN, LISP, Smalltalk, Python, Perl, Java, Ruby, or even most variants of BASIC, we'd never see another buffer-overflow exploit again.

      We use C primarily because we like it, but let's not pretend that it's a well-designed language, please.

      As for SQL, I don't know anyone who actually likes it, we put up with it because that's what the DBMS's we need to use can understand. If Tutorial D can improve my quality of life when I have to deal with a DBMS, I'll give it a good hard look, at least.

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    2. Re:I gotta say ... by Daniel+Dvorkin · · Score: 2, Interesting

      My point is, basically, this: C was designed by programmers who wanted to create a versatile, powerful language that would get the job done, while Pascal was designed by a theoretician who had a fanatically pure vision of what a programming language should be ... and as you say, people like C, and it shows, which is why the bulk of programming today is done in C or one of its descendants, while Pascal is essentially a footnote in computing history at this point.

      SQL vs. Tutorial D (or any of the other "more correct," i.e. closer to the relational calculus, DB languages that have come and gone) strikes me as much the same sort of thing. FWIW, I do like SQL, and in much the same way as I like C -- I may grumble at its limitations and weirdnesses, but by and large it gives me an intuitive, effective way to get the job done.

      --
      The correlation between ignorance of statistics and using "correlation is not causation" as an argument is close to 1.
  10. I was about to ask the same thing. by Mustang+Matt · · Score: 4, Insightful

    Seems like it can handle just about everything but maybe I'm not thinking outside the box. The biggest limitation is my lack of knowledge about how to do the things I want to do.

    --
    The man who trades freedom for security does not deserve nor will he ever receive either. - Benjamin Franklin
    1. Re:I was about to ask the same thing. by BoomerSooner · · Score: 4, Insightful

      The authors said when you do a query where your float field is null you dont get the instances of null. They say this is a problem but I say bullshit. It's the fault of whatever allowed null to be the value of that field instead of 0.00 or whatever. The data with null didn't magically appear there.

      I agree sql could be better but the more complexity you add the more bullshit code I'll have to figure out what programmers were doing when I'm hired to fix their code. The company I currently work for has stored procedures that are over 4,000,000 lines (total) for report generation. Amazing how difficult it is to debug and work with. Especially since it was done in Transact SQL. I'm probably biased toward PL/SQL because I learned it first but it is so much easier to code in than Transact. (I have about 5-6 years of working in TSQL and about 7-8 in PL/SQL)

    2. Re:I was about to ask the same thing. by Kell_pt · · Score: 2, Insightful

      I think you kinda misunderstood the problem.

      The fact that there CAN be nulls is a showstopper when attempting to think in terms of relational algebra. It's so much simpler when you have a sound foundation of maths underneath - SQL has been so distorted over time that there is AMPLE room for improvement.

      By not allowing nulls you are in fact working in a simpler world, as you do not have "undefined" operations in your query.

      You are right though, in that it's the designers fault if NULLs get there, that's true. But just the fact that it exists forces a whole pletora of mechanisms and distorted concepts to deal with it. It's a poor man's attempt for an "incomplete-data" solution. A real incomplete-data solution must allow for the 3 boolean tests:


      Known - true Known - false Unknown


      Seeing as all comparisons in SQL are just boolean, they "trick" the third state into behaving within boolean parameters. And that's a source for trouble that could be avoided and made a hell of a lot simpler.

      --
      "I don't mind God, it's his fan club I can't stand!" E8
    3. Re:I was about to ask the same thing. by a_ghostwheel · · Score: 3, Insightful

      Pretty much the only reason NULLs so widely used is due to performance implications. Any nullable field can be easily normalized by moving data to separate table with NULL value being represented by absence of the record in the new table. But you will pay significant performance price.

    4. Re:I was about to ask the same thing. by BlackHawk-666 · · Score: 2, Insightful

      How do you represent the missing fields in a LEFT OUTER JOIN, you know, the ones that were implied to be NULL by their abscence. You need something to represent the abscence of data, and if you don't use NULL or other metadata you need to use a program assigned value...and that's even more hassle.

      --
      All those moments will be lost in time, like tears in rain.
    5. Re:I was about to ask the same thing. by jafomatic · · Score: 2, Interesting
      Why not select the result of your join(s) into a new table whose schema will default those nulls to 0.00?

      Am I missing a requirement? This seems like it shouldn't be an issue.

      --
      ::jafomatic
    6. Re:I was about to ask the same thing. by Kell_pt · · Score: 2, Interesting

      A couple valid points here and in the other few posts.

      I'm not an academic, and I do write SQL a lot. Actually, I end up trying to write as little SQL as possible, by insulating it into small functions, but I'm sure many do the same for portability and plain old good form.

      As for NULLs, the example of an empty street address is best represented by ''. Because the upper layer (the client used to fill in the values) won't make a distinction between '' and NULL.

      In most cases, I simply ignore NULLs, and force propper default values - I'm sure most do the same.


      The question we should be placing is "is there a better way"? Is there room for improvement? And please don't bring XQuery to the equation, that's something driven by need, not by carefully designing a solution.

      At least fostering discussion and looking for alternatives, we might be able to achieve something. ;)

      --
      "I don't mind God, it's his fan club I can't stand!" E8
    7. Re:I was about to ask the same thing. by EastCoastSurfer · · Score: 5, Insightful

      0.00 != null

      Zero is implying that there is a value there and that it is in fact the number zero. Null would imply that no value ever existed, zero or otherwise.

      In all of my db designs I try to avoid nulls unless absolutely neccessary. A typical situation where nulls are unavoidable would be in an end date field( no end date as of yet). You also usually get nulls back when doing outer joins.

      Remember though that null != 0 != ''. Null is the complete absence of a value.

  11. Me and my buggywhips by bigattichouse · · Score: 3, Funny

    My buggywhip manufacturing plant uses good old fashioned chained flat files. No one in their right mind would EVER use some *toy* database structure, especially that whole relational database poppycock. balderdash!

    --
    meh
    1. Re:Me and my buggywhips by Timesprout · · Score: 4, Funny

      You and your newfangled buggy whips. Here in the real country we ride horses the way the good lord intended. When we need to store data we just tell old Uncle Jim and he remembers it. Uncle Jim even invented relational data, why he can tell you just about anything the famiily ever done right back to when great great great great great great grand pappy Bill ran away to marry his 14 year old cousin Mary Lou.

      --
      Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
      What truth?
      There is no dupe
  12. Ever heard of TSQL? by Sean80 · · Score: 4, Interesting

    Ever heard of TSQL? Neither would have I, if I hadn't been forced to read about it in college. It would seem that there has been a huge number of variants of SQL over the years that have tried to make it "better." The benefits just never seem to outweigh the cost of learning a new language.

    1. Re:Ever heard of TSQL? by ajs · · Score: 2, Insightful

      The cost is not in learning. People learn new languages every day. The problem is in compatibility.

      Let's say that tomorrow MySQL adopts Tutorial D. Ok, so you are going to write code that talks to MySQL and you think about Tutorial D.... well, MySQL still talks SQL, and it turns out that so does everything else. Someday you may want to switch databases because suddenly DB2 is all the rage. If you use Tutorial D, you can't switch.

      Any move away from SQL would have to be a broad industry move or would have to come from an effort that is so divorced from the current uses of databases that compatibility simply is not an issue.

    2. Re:Ever heard of TSQL? by radish · · Score: 2, Informative

      Strictly speaking Transact SQL is Sybase's variant. Microsoft adopted it when they forked SQL Server from them.

      --

      ---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"

  13. Don't forget microsoft's X-Query by joel2600 · · Score: 3, Interesting

    For those of you that haven't been assimliated into the borg, microsoft's new version of SQL server accomodates for a new query language called XQuery which takes a lot of the best parts of XPath and XSLT and combines them and obviously the underlying framework is XML. This will cover a lot of the shortcomings over Transact SQL for those that are willing to adopt it, and honestly, it's really not that bad.

    1. Re:Don't forget microsoft's X-Query by PhrostyMcByte · · Score: 4, Informative

      XQuery is a standard, not one of Microsoft's creations.

    2. Re:Don't forget microsoft's X-Query by Anonymous Coward · · Score: 2, Informative

      XQuery is a standard

      For the love of $DEITY, not everything remotely associated with the W3C is a standard. In fact, virtually nothing they do is a standard. Tim Berners-Lee was extremely careful when setting up the W3C to emphasise that they weren't a standards body.

      CSS? Not a standard. XML? Not a standard. XHTML? Not a standard. "Web standards"? Not standards. HTML? HTML has actually been standardised by a real standards body, and so, if you are using ISO-HTML, which is a stricter version of HTML 4.01 Strict, then yes, you are using a standard. But if you are using any other form of HTML, then no, you aren't using a standard.

      XQuery? That's just a public specification. An incomplete, draft specification at that.

    3. Re:Don't forget microsoft's X-Query by SoupIsGoodFood_42 · · Score: 2, Insightful

      Yeah, yeah. We all know that hardly anything the W3C do are true, bona fide, ISO standards, but they are still standards as far as most people are concerned. No need to be so pedantic.

  14. Worth ditching SQL? by jack's+wasted+liver · · Score: 2, Insightful

    Any language is going to have quirks and inconsistencies between dialects.
    SQL has worked so far but if Tutorial D really is better then bring it on.

    I've gotten over SQL the "short commings" though

  15. Not a replacement language... by ryanmfw · · Score: 5, Insightful

    If you read the article, this isn't about replacing SQL, but more about testing new ideas and languages that could replace SQL. This is better than just saying, "We have a better language. Switch now or be assimilated.", and I'm glad someone's finally taking this approach. Unfortunately, the article only mentions one specific problem with SQL, but I'm sure there are others that these people might eventually solve.

    --
    Hurricane Ivan: A 17th century prison collapsed. All of the inmates escaped.
    1. Re:Not a replacement language... by Timesprout · · Score: 2, Interesting

      I agree, it seems more experiment based than anything. Its a good idea as well. We all know SQL has shortcomings (hey nothing is perfect) and the OO database concept seems to have died a death. There are a lot of ORM tools and persistence frameworks coming into mainstream adoption now to avoid SQL in general day to day development. Several of these also have their own 'query language', so why not have another look at the root language.

      --
      Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
      What truth?
      There is no dupe
    2. Re:Not a replacement language... by lucabrasi999 · · Score: 2, Funny
      If you read the article

      Even if I couln't see your UID, that phrase above would give you away as being "new around here".

    3. Re:Not a replacement language... by Tablizer · · Score: 2, Informative

      Unfortunately, the article only mentions one specific problem with SQL

      Here is an informal list from the c2.com wiki:

      # Nesting makes it harder to factor out duplication as opposed to (optional) named units
      # Group By inconsistent and/or confusing
      # Implementations are inconsistent between vendors
      # Standard lacks tree-based operations. What tree-based operations would be compatible with a relational model? Transitive closure? The point is that everyone comes up with various ways to hack up trees in SQL (e.g discussed in "SQL for Smarties", Joe Celko), but the hacks tend to be awkward and slow, so some people think that some model of trees, any model of trees [or graphs, or multigraphs], should be native to SQL to avoid the need for hacks. See http://docs.alphora.com/D4LGExplode.html for an implementation of the EXPLODE operator proposed by Chris Date for hierarchical queries. {Move to RelationalAndTrees}
      # Inconsistent syntax (see below)
      # Large, complex syntax instead of using combinations of simpler syntax units. Think of comparing the COBOL parse tree (or generators) to C's or Lisp's parse tree. Moved discussion below.
      # Nulls are a flawed concept. Especially for strings.
      # Defaults to generating duplicates, which can cause confusion and erroneous results.
      # Encourages long, hard-to-digest run-on "sentences"
      # Not a DBA-extendable language (see BusinessSystemTwelve)
      # Joins could be simplified if using "standard" links (WhereAndAnd)
      # The formal specification is too damned huge
      # Many SQL-based systems don't allow user-defined views (DatabaseFlaws?)
      # Column aliases are sometimes not recognized in outer queries
      # SQL's syntax is prone to security problems: SqlStringsAndSecurity

  16. SQL is good for some things, but not for others by Rand+Huck · · Score: 2, Insightful

    One big thing I think a database could use is a hierarchy key instead of using parentid's as "foreign keys", is just one of the shortcomings. If I wanted to make a threaded thing for my forums, for example, I'd have to make a big PHP script just to sort it properly. I would have loved to have MySQL do it automatically. SQL has a very limited syntax, as well, and is inconsistent. "INSERT INTO table VALUES ('', '', '');" That's one of the only times you see the parenthasis used in that way. You don't see it here: "SELECT * FROM table WHERE id = '';" or "UPDATE table SET id = '';" I would like to have the ability to easily use my own functions just as you do with any language. It's especially important in database software.

    1. Re:SQL is good for some things, but not for others by glwtta · · Score: 5, Interesting
      I think you are confusing "SQL the language" with "MySQL the broken RDBMS implementation", both Postgres and Oracle can easily do what you want with hierarchies; as for user defined functions, support for those is implicit in most database systems (usually in a variety of languages, both SQL dialects and procedural).

      I am not sure what's incosistent about the syntax you mentioned, but maybe that's just me. Though I'd be interested to see in what ways it is "very limited" (especially if those aren't the limitations of a particular databas engine, or relational databases in general).

      --
      sic transit gloria mundi
  17. Re:Grammar? by e9th · · Score: 2, Funny

    Hey! Having graduated colledge as a technical writer, much of whose work has been lost due to virii on my boxen, I think you are being unfair. I hope you loose your job, as I did.

  18. Re:Grammar? by LiquidCoooled · · Score: 3, Funny

    UPDATE tblUsers SET Karma=Karma-1 WHERE UID=743982;

    --
    liqbase :: faster than paper
  19. This could mean... by Performaman · · Score: 4, Funny

    that SQL is SOL.

    --

    I have gas, but my car uses petrol.
  20. Comment removed by account_deleted · · Score: 2, Interesting

    Comment removed based on user account deletion

  21. Tutorial D... by malakai · · Score: 2, Interesting

    It might be logically 'perfect' in terminal of relational math, but as a language, it's obtuse. The only book I could find on Bi Temporal database design ended up with all the tutorials written in this Utopian/Acadamian SQL language... holy crap was that annoying.

    The reaons for wanting a change from SQL I agree with, but Tutorial D you'll never catch me using.

    We need something to combine the power and speed of SQL query syntax with the nested filtering ability of XPath, yet doesn't require the entire DOM to be in memory to work.

  22. Predicate Imputation by Baldrson · · Score: 3, Informative
    I've been watching the way relational calculus has been studiously ignored by both academia and industry for over 20 years now. Date and Darwen make some noise about recognizing that SQL's foundation is the application of predicate calculus to set theory but don't really do much of anything that would be recognizable to Pierce, Russell or Whitehead. Moreover, their "manifestos" about things like the object-relational paradigm don't do much to get to the heart of the issue from first principles.

    Almost all the Object Oriented stuff people layer on predicates are, at best, an ad hoc, and poor, means of optimizing execution speed.

    Let me explain.

    One of the principles of polymorphism is that the same method has the same abstract meaning regardless of the kind of object. A predicate considered as a method subsumes such polymorphism by simply trying the various possible implementations of the method and committing to only those that succeed. If more than one succeeds then so be it -- that's the whole idea of relations as opposed to functions.

    So, one reason you want all this OO stuff is the inheritance hierarchies keep you from going through all possible interpretations of a given method when the vast majority of them will fail for a given object.

    Another, related, problem is that inheritance provides defaults without requiring a lot of thinking on the part of the computer. What I mean by "thinking" here is the sort of thing that is done by statistical imputation of missing data via algorithms like expectation maximization (EM) or multi-relational data mining via inductive logic programming.

    So, the other reason you want all this OO stuff is so you can avoid mining a background database to provide reasonable defaults for various aspects of the data.

    Some might be concerned that over-riding isn't absolute in such a system -- that you don't absolutely block, say, more generic methods when you have more specific ones present, and they're right. You don't block those methods -- you lower their priority by lowering the probability of those implementations via the statistical methods of imputation and/or induction. In a microthreading environment they most likely won't get any resources allocated to them before other higher priority implementations have succeeded. In a single threaded/depth-first environment they will be down the list of desired alternatives -- but they won't be discarded until something equivalent to a prolog cut operation kills them off.

    However, and this is the important point, the work that has been expended toward OO facilities has vastly outstripped the effort that which has been put toward more parsimonious ways of optimizing predicate systems.

    One of the better predicate calculus systems out there -- more promising due to its use of tabling to avoid infinite regress on head-recursive definitions and its optimization of queries using some fairly general theorems of predicate calculus -- is XSB. It has an interface to odbc and a direct interface to Oracle, but it would be better if it had something like a recoverable virtual memory substrate to support its roll-back semantics.

  23. Sourceforge project page by lub · · Score: 3, Informative

    Is right here.

    From the introduction: "Rel is intended to serve multiple purposes:
    -It is a tool for learning, teaching, and exploring relational database concepts in general;
    -It is a tool for discovering the power and expressiveness of a true relational language;
    -It is a tool for learning Tutorial D;
    -It is a relational database server;
    -It may serve as a prototype or "working blueprint" for future implementations of Tutorial D or any "D" language (more on this later);
    -It may serve as a platform for experimenting with and/or examining database engine internals. "

  24. Re:Grammar? by 808140 · · Score: 2, Informative

    Dude, do you hear that whooshing sound? It's the the sound of the GPs joke going right over your little head.

  25. Re:sql sucks by MavEtJu · · Score: 2, Informative

    If it becomes too complex because of too many tables, make some views which reduce the complexity for generic parts of queries.

    --
    bash$ :(){ :|:&};:
  26. Link to the actual project by The+Pim · · Score: 2, Informative

    Geesh, links to a press release and trade rag article, and not even the name of the project itself? Go read some real information about Rel, look at the examples, download the source, have fun.

    --

    The evaluation of an action as 'practical' . . . depends on what it is that one wishes to practice.
  27. Benefits of alternative languages by jesterzog · · Score: 3, Insightful

    For those interested, the paper describing this language (linked to from the article) is available here. There's a link to the grammar of the language at the end of that paper.

    I use SQL quite a lot. It's certainly great for a lot of things, but it does have some limitations here and there. For instance, trying to deal with things like hierarchical structures, or joining on having identical/similar children, is a nightmare in SQL. Even if the query doesn't need to be efficient to run, it can still be extremely complicated to write and test. SQL simply wasn't designed or intended to deal with those sorts of structures.

    Unfortunately, short of using external code outside the database, it's so often a choice between using SQL or nothing else for writing a query in a particular database rather than an option between SQL and another language. In some ways it's like being forced to write every program in C or every program in Java or every program in Lisp, where realistically one or another might be better suited to a particular task.

    I suppose one of the reasons for only supporting SQL is that a predictible query language makes it easier to arrange data structures so they can be queried most efficiently. Still, it'd be nice to see an alternative front-end language or two supported in one or more of the major databases. Not every query needs to be ultra-efficient, and there have been many times where I would've liked to trade an efficient query execution for a language where what I wanted was more writeable.

  28. Comment removed by account_deleted · · Score: 3, Interesting

    Comment removed based on user account deletion

  29. Re:The shortcomings of SQL - Postgres by paul.schulz · · Score: 2, Interesting

    Prior to PostgreSQL, the Postgres database
    was based on another query language other than
    SQL.

    One of the main reasons why
    PostgreSQL took off after this was that
    it changed over to SQL in response to
    community/industry request and requirements
    (and openness to community contributions),
    bringing it in line with the industry
    standard.

    I suspect that the next evolutionary step will
    be to allow multiple query languages to be used
    on the same DB engine.

  30. It's not about optimization... by Ayanami+Rei · · Score: 5, Informative

    this proposed language is like a superset of sql. It also sort mixes itself with PL/SQL-like constructs as well. I think it's rather novel and it could make your optimization tasks easier if you had access to something like this... less trying to think in terms of the language, more in terms of how you want to acutally manipulate the data.

    This is _not_ a query builder. It's going back, looking at what relational algebra is, seeing what people do with SQL, and then making sure the language has all the idioms required to be "complete" and not arbitrary.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
    1. Re:It's not about optimization... by pdjohe · · Score: 4, Informative
      Here's a bit of the language enhancements from D-Tutorial. (Note also, that D-Tutorial is the initial building/learning form of future "D" languages.) I'll admit it does simplify things...

      INSERT: A shorthand syntax is available for INSERT. The following:
      INSERT INTO r RELATION {TUPLE {x 1, y 3}};

      May also be specified as:
      INSERT r TUPLE {x 1, y 3};
      Or:
      r += TUPLE {x 1, y 3};
      The lattermost syntax is intended to be vaguely evocative of the "increment by 'n' and assign" operator found in C, C++, Java, and other languages. DELETE: A shorthand syntax is available for DELETE. The following:
      DELETE r;
      May also be specified as:
      r -= ALL;
      The following:
      DELETE r WHERE x = 2;
      May also be specified as:
      r -= WHERE x = 2;
      Or:
      r -= [ x = 2 ];
      The use of "-=" is intended to be vaguely evocative of the "decrement by 'n' and assign" operator found in various popular programming languages. UPDATE: A shorthand syntax is available for UPDATE. The following:
      UPDATE r WHERE x = 2 SET ( y := 3, z := 4);
      May also be specified as:
      r @= WHERE x = 2 SET ( y := 3, z := 4 );
      Or:
      r @= [ x = 2 ] SET ( y := 3, z := 4 );
      Or, because SET is optional:
      r @= [ x = 2 ] ( y := 3, z := 4 );
      Comments: Comments are specified using conventional C++ and Java syntax. Eg:
      // This is a comment line

      /* This is a multi-line
      comment block */
      More info and examples here.
  31. Null is not Zero in SQL by Magickcat · · Score: 4, Insightful

    The article criticises SQL but the author has little familiarity with SQL for example:

    "but the syntax is often inconsistent and unless you use one of the many vendor-specific supersets of SQL it can be tricky to express complex series of operations in a concise manner."

    But in fact, SQL is so popular because complex expressions need little changing from specific vendor offerings. If people choose to program using the subsets, then well and good, but the ANSI standard is generally thought to be sufficient. This is like arguing for the abolishment of HTML and XHTML because Microsoft make a flawed browser - hopefully the database language is better than the reasoning here.

    It then goes on to say "The idea is that there should be no arbitrary restrictions on the syntax of the query language, but at a lower level the database shouldn't run up against idiotic limitations. The limitation in existing implementations that generates the most comment from the various parties in the debate is the problem with "null" values in relational databases. Put simply, a database field has a type (50 characters, for instance, or a floating point number to two decimal places, or an 8-bit integer), but when you don't fill the field in (i.e. it's "null") it loses all its meaning. Even the ANSI standards state that if a field is null it's said not to exist - so if you ask a database for "all entries where field X is not equal to 47" it won't return any of those where field X is null because instead of saying "Null doesn't equal 47", the value "null" is deemed not to be comparable with any non-null field."

    Well, for starters, null is not numeric zero, null is the absence of any data whatsoever, and every SQL doc in the world tells you to not mistake it for zero. Any arithmetic expression containing a null always evaluates to null. For example, null added to 7 is null. All operators (except concatenation) return null when given a null operand. That's exactly why it's the ANSI standard.

    If you want to find "all entries where field X is not equal to 47" then pass your attribute a value like "0".

    SQL is neither clunky nor obsolete. Tutorial D may actually be a better database modelling method, but the article's criticisms aren't sufficient to exault Tutorial D whatsoever. The "Project D" syntax and model may possibly be better, but these criticisms aren't a convincing reason to scrap SQL.

    --

    Si tacuisses philosophus mansisses. If you had kept quiet, you would have remained a philosopher.

    1. Re:Null is not Zero in SQL by Magickcat · · Score: 2, Informative

      Null is the absence of any data, but the author is criticising it because he thinks it should behave the way numeric zero does in a variable. If he wants his attribute to act like "0", then it should in fact be "0".

      SQL by design distinguishes null from "0" - it's not a limitation or a flaw in the design, it's quite deliberate, but it's a distinction that people who are not familiar with SQL often get confused about.

      --

      Si tacuisses philosophus mansisses. If you had kept quiet, you would have remained a philosopher.

  32. SQL joins. by FooAtWFU · · Score: 3, Informative
    Yes. Investigate the wonderful world of SQL joins. Generally, you'll find yourself doing something like, oh, I don't know:

    select client.name, client.id, product.id, product.name, product.price from client_table client, product_table product where client.id = product.client_id and client.id = ? and product.discontinued = 0 order by product.price

    Assuming you substitute something for ?, that will effectively join the two tables into one, and give you a list for all products from a certain client (given by ID) which have not been discontinued, and order these results by price.

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
  33. I think he's trying to say: by Ayanami+Rei · · Score: 4, Interesting
    I think he's trying to say that joins shouldn't be this hard to describe in the language.
    Compare the symbolic forms:
    Example, theta join
    And the implementation in SQL:
    SQL join example

    Specifically in Tutorial D (and hence Rel) you would do this:
    T1 = JOIN(EMP, DEPT)
    And subsequently do shit with T1. That's it.
    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
    1. Re:I think he's trying to say: by Gilk180 · · Score: 2, Insightful

      That may be, but I haven found few operations easier to express in relational algebra than in SQL.

      for example:

      I want the name field from a if it's id is in b.

      In relational algebra,
      PROJECT[A.name](THETA_JOIN[A.id=B.id](A, B))
      or
      p[A.name](A |X|[A.id=B.id] B)
      Sorry, ascii sucks.

      In SQL
      SELECT DISTINCT A.name FROM A,B WHERE A.id=B.id;

      I find the SQL version to be more readable, etc. The same functionality is provided by both and is easily transferable.

      cartesian production becomes SELECT * FROM A,B

      natural join becomes (A NATURAL JOIN B)

      theta join becomes SELECT DISTINCT * FROM A,B WHERE

      selection becomes SELECT * FROM A,B WHERE ...

      projection becomes SELECT columnA, columnB FROM A,B

      With nested queries, everything is easily translatable from relational algebra to SQL (Technically, all SELECTS should be SELECT DISTINCT, but whatever). Otherwise, temporary tables can be used.

      The real reason relational algebra seems easier to deal with is because you can use symbols to represent things and there are no data types. It is an abstract language that cannot be implemented because it is under-defined.

      If you try expressing a hairy SQL query with relational algebra syntax, you will end up with a hairy relational expression.

  34. RPG by stanwirth · · Score: 2, Funny

    RPG already overcomes the shortcomings of SQL

  35. Null=Null is Null, except Group in Group By by Saint+Stephen · · Score: 2, Funny

    One of my favorite idiosyncracies with null is Null = Null is Null (unless you turn that off in the DB), but Group by groups together equal values except it also groups nulls!

  36. Any query language is going to be ugly... by 1iar_parad0x · · Score: 2, Interesting

    I looked at the articles, which are too broad by the way, and I didn't see enough of an explaination to make out real detail.

    However, it seems as if Tutorial D is nothing more that a purely mathematical improvement of SQL. In other words, it's like comparing Lisp to Prolog or ZF Set Theory to HBG. (Okay, I'm not a logician..., so you math wizards can hold off on the flames.) I'm all for improving SQL. It just seems like Tutorial D addresses the usual complaints about the hazy concept of a NULL in a database.

    SQL or any derivative thereof will be inherently complex. This is because SQL is merely an implementation of Relational Algebra. That's the key. Real RDBMS's are inherently mathematical in nature. Complex SQL queries are tough. Too often the average database programmer couldn't even tell you what the definition of a set, function (i.e. the mathematcial definition), or a cross-product is. Yet, they'll write code (or not) that incorporates complex joins. Incidentally, they'll do the same thing with regexs too. Programming still has it's deeply mathematical roots. Not as much as I'd like, but still...

    In short, if you're looking for some cool new English Query tool to save the day, you won't find it here. Still, if you're a SQL wonk looking for a new toy or an improved SQL, this may be of interest to you.

    Oh, by the way, I used to have a copy of Date's database book. I sold it along with my copy of Foley and Van Dam, Sipser's Theory of Computation, and Aho and Ullman's compiler design book [the "dragon" book] because I needed to pay the rent. Interestingly enough, the books retained a pretty high resale value even after all these years.

    --
    What do you mean my sig is repetitive? What do you mean my sig is repetitive? What do you mean....
    1. Re:Any query language is going to be ugly... by Tablizer · · Score: 4, Interesting

      SQL or any derivative thereof will be inherently complex. This is because SQL is merely an implementation of Relational Algebra. That's the key. Real RDBMS's are inherently mathematical in nature.

      I disagree with the "ugly" premise. I have been working on an SQL replacement language myself (described briefly in another thread). I don't believe that (practical) relational operations are inheritantly complex or confusing. There are two problems with the way SQL and/or relational is often presented that gives the false impression that relational operations are inherantly messy, unnatural, and/or confusing.

      First, the "base" operations that Dr. Codd presented with his relational papers are not necessarily the same operations that a relational language needs to present to the user (programmer). For example, in Boolean algebra, the "purist" (and only) operation is NAND (NOT-AND). Any of the other operations can be built with NAND alone. However, humans generally don't relate to NAND because our language has gotten us too familiar with AND, OR, and NOT. We thus use the human-friendly operations instead of the "purist" operations. The trick is to find relational operations that are friendly to humans, yet are still based on the "base" operations. As long as they are defined via the base (proper) relational operations, they are valid.

      Second, SQL does not make it very easy to break big problems into smaller problems. The approach I envision would allow this. There would be intermediate virtual tables that would feed to later operations. One can concentrate on creating one virtual table at a time.

      x1 = foo(....)
      x2 = glab(....)
      result = join(x1, x2, ....)

      One can refer to chunks via name, whereas SQL forces one to nest stuff to acheive the same thing. (Plus, SQL sometimes requires one to duplicate something if two different "roots" of the parse tree need the same construct. By-reference instead of by-nest would fix the duplication.)

  37. Perhaps it is interesting. by abulafia · · Score: 2, Insightful

    And if it were actually relational, then it might be interesting in the current discussion. But it ain't. That it comes up is funny, in context, because mistaking things like XML for relational is something that Date regularly has massive heart failure over.

    --
    I forget what 8 was for.
  38. Sounds like... by TheVidiot · · Score: 3, Funny


    Jack Black and some bald dude have gotten into databases?

  39. SQL is a poor relational data model implementation by ikewillis · · Score: 3, Informative
    I don't think lottameez's problem was so much with the concept of a join but the semantics of SQL and how it implements the relational data model.

    SQL was a language designed to allow relatively unskilled operators to be quickly trained for data entry using the language directly, and thus it was designed to be English-like, flexible, and forgiving.

    SQL is only vaguely reminiscent of the true mathematics behind the relational data model. It continues to be used and expanded, despite its restrictions and shortcomings, because it is far and away more popular than any other database language.

    The fundamental assumption of the relational model is that all data is represented as mathematical relations, or rather, a subset of the Cartesian product of n sets. Unlike SQL, in the mathematical model reasoning about such data is done in two-valued predicate logic (that is, without a null value), meaning there are two possible evaluations for each proposition: either true or false. The data is operated upon by means of a relational calculus and algebra.

    The relational data model permits the designer to create a consistent logical model of the information to be stored. This logical model can be refined through a process of database normalization. A database built on the pure relational model would be entirely normalized. The access plans and other implementation and operation details are handled by the DBMS engine, and should not be reflected in the logical model. This contrasts with common practice for SQL DBMSs in which performance tuning often requires changes to the logical model.

  40. Re:sql sucks by fupeg · · Score: 2, Interesting

    As many others have pointed out, there are decent tools out there for generating SQL for you. I've used Hibernate quite a bit. It has saved from writing a ton of SQL, but I've still written a lot of HQL (Hibernate Query Language.) Hibernate also has a Criteria class for completely eschewing a query language in favor of purely programmatic queries. It is very limited though.

    All that being said, the problem with Hibernate and any other SQL generator is very simple. They are not themselves querying and accessing data. They are specifying an intermediate language that is then in turn parsed and executed. If writing SQL is liking speaking to a translator, then using Hibernate is like speaking to a translator who then speaks to another translator, etc. What the Tutorial D guys are after is a native language that makes the translation(s) as transparent as possible.

  41. My work on this by Tablizer · · Score: 3, Interesting

    I have been working on an SQL alternative myself for a while. My approach is more functional (not procedural) in nature. If the language is designed based on this, then new operations can be added without having to add to the syntax of the language. This would help vendor compatibility because if vendor B does not offfer an operation that vendor A does, then a DBA can simply add a clone of the "function" without tweaking the language parser.

    Tutorial D uses infix notation, which tends hard-wire operations to a syntax parser. Prefix (functional-style) is more flexible, consistent, and easier to parse. For example, new parameters can be added to prefix without changing existing calls. It is just an extra, perhaps optional, parameter. It is hard to do with with infix.

    My relational replacement would also make it syntactically easier to perform relational operations on things such as column name lists. The column list is simply a table in its own right (perhaps with syntactical shortcuts); thus it can have table operations (relational algebra) done on it just like tables. It is "conceptual reuse" you can say.

  42. Why not awk? by Anonymous Coward · · Score: 2, Interesting

    We (BitMover, the people who produce BitKeeper) are building a database on top of our SCM system (yes, that's a little weird but it works out well).

    We played around with straight SQL syntax, flirted with ruby as the syntax, and ended up with awk (actually nawk). It was the best balance between simple enough for normal people to understand and powerful enough to get the job done.

    So we can do stuff like

    bk db -s'select from bugs /xyzzy/ {print $ID}'
    bk db -s'select from bugs where $OWNER == "rob" {print $ID}'
    bk db -s'select from bugs where $OWNER =~ /rob|lm|wscott/ && $STATE =~ /open|assigned/ {print $ID, $SUMMARY}'

    etc. The where clause and the print clause (print is implied) are full on awk scripts, do whatever you want with them.

    We're big fans of not reinventing the wheel. Awk is a little weird but it's 95% of the way there and a few tweaks made it perfect for us. So why invent a whole new language? Especially when all the awk code is about 100K of text on x86 and includes a full on regular expression library.

  43. I think with Rel... by Ayanami+Rei · · Score: 2, Informative

    that they are trying to give you the best of both worlds. Expressions that can be expressed simply in SQL have short forms in the language too. Expressions that were hard to express in SQL but easy in R.A. are still pretty basic forms.
    By not trying to be like SQL, and more like {T,PL}SQL, I think they get the freedom they need.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  44. in anger??? by thomasa · · Score: 3, Funny

    Quote
    Most people who use databases in anger are familiar with the concept of a relational database.
    Unquote

    Maybe someone could enlighten me as to why the word
    anger is in the first sentence of the article. Why
    would using databases in anger be relevant? I use
    databases in finanical situations, is that similar
    to anger?

  45. you were born too late by kpharmer · · Score: 2, Insightful

    see, if you were born around 1940 you could have been using IMS/DB, VSAM, ISAM, IDMS, etc back in the 70s.

    Tons of opportunities there for low-level access to your data. Of course, there's a reason that all those database management systems were abandoned for a 'busted ass super high level language'. It's because they sucked to maintain, they didn't evolve well as business requirements changed over time, and if you had the *most* basic of business questions - you'd never get an answer without a month of writing code.

    But don't despair - pick up a little more SQL and you may find it isn't that tough.

  46. No new languages needed. by Doc+Ruby · · Score: 4, Insightful

    By creating a new language, "Tutorial D", developers are excluding the other languages as much as they're including new features in the new language. Why not just add a Java package that includes the new syntax? To get anywhere in software development, even Tutorial D code will have to interoperate with existing systems and programmers with existing skills. Someone will have to code a "Tutorial D" JDBC driver, and ODBC, and all kinds of middleware that eats performance, developer time, and introduces the maintenance pitfalls of complexity. And by adding a package to an existing language, they can skip reimplementing the features of the existing language that they include in this new one, like loops, branches and character output. The effort seems as vain as the endless 19th Century conceits of inventing complete philosophical systems from scratch, to serve the reputations of egomaniacs dominating university debates. Why can't everyone just speak Object, with procedural slang and set-theoretical poetry?

    --

    --
    make install -not war

  47. Not the first. by leandrod · · Score: 2, Informative

    It is not true that no one ever did anything with Date's and Darwen's ideas on a relational language. Check, for instance, the category I edit at the Open Directory, or even Darwen's own The Third Manifesto website with its list of projects.

    Probably the poster is confused about the nature of Tutorial D. As it names indicate, it is but an example of a possible 'D', and one targeted at instruction at that. This accounts for its COBOLishness. It is possible to implement a non-Tutorial D that is completely faithful to the Relational Model and the Third Manifesto, yet has a distinct flavour.

    For example, Alphora Dataphor implements D4, which was a compliant D until having had to incorporate SQL NULLs quite recently, and it has a Pascal flavour to it; Opus and Duro are C-like; there was a guy wanting to implement a C#-like D-flat language; Alfredo Novoa is implementing Tutorial D itself in MS.Net; and so on.

    By the way, it is interesting that until now the more ambitious projects, that seem to be Alphora's and Mr Novoa's, are in MS .Net. Time for the free software community to rise to the challenge!

    --
    Leandro Guimarães Faria Corcete DUTRA
    DA, DBA, SysAdmin, Data Modeller
    GNU Project, Debian GNU/Lin
  48. Re:NULL is problematic. by slamb · · Score: 5, Insightful
    Yes, for this reason, if I were designing an SQL replacement, NULL would not remain as it is. I would probably replace it with two values, UNKNOWN and INAPPLICABLE, corresponding to the two cases you described. In fact, Dr. Codd, the father of relational algebra, suggested having multiple types of NULL. (There might even have been more than two. I don't remember what the others were.)

    I might also introduce keywords POSSIBLY and CERTAINLY that collapse tri-state logic (true, false, maybe) into boolean logic. Thus, POSSIBLY(a = 5) would be true when a is UNKNOWN but CERTAINLY(a = 5) would be false.

    Date advocates a different approach - no NULL at all. Instead, he has some sort of parallel table structure; a row in one table for the value being present and in another for the value being absent. With some more complex way of constraining it so there would be no contradictory information in the tables. I don't like this approach - having no NULLs seems simpler than having two, but not once you add in the weirdness of contraints. And not once you realize many tables have multiple nullable columns. Joining so many tables together would get ridiculous quickly.

    In practice NULL seems to not be a huge problem for me. Occasionally a field can either unknown or inapplicable, and I need to distinguish between the two; I have to do a kludgy thing with another field and a CHECK constraint. But for the most part, it's just an extra half second of thought when writing the logic, which isn't too bad. But it does trip newcomers. It would be worth fixing if you were designing a new relational query language from scratch.

  49. Re:So... by Tablizer · · Score: 2, Insightful

    Why don't you participate in the development in one of the OSS database systems (like Postgres) to [add temporary views] Bingo, there is your 'variable' functionality without inventing a whole new language.

    1. It is not that likely that I will get a chance to use it at work.

    2. SQL stinks in other ways that I would like to see fixed. In other words, I think it is time to explore a complete overhaul. Why be stuck with a "good enough" language forever? We are finally getting away from COBOL as the dominent biz language, so how about we work to get away from its relational cousin known as SQL?

    They keep tacking stuff onto COBOL to try to modernize it, but the result is a language only a mother can love. They are even adding OOP to it.

  50. Vendor Lock-in is a myth for me by mcrbids · · Score: 4, Informative

    I use PostgreSQL for all my DB stuff. Comparing it to MySQL is like comparing a mini-pickup to an 18-wheeler. PostgreSQL ANSI support is good, and it's very stable.

    When I write custom apps (pretty much all I do) I write to the full capabilities of PostgreSQL. It's "man enough" to handle the biggest projects I'll likely ever see, and I'm not worried that the vendor will up and leave, since there isn't one.

    In fact, PostgreSQL has had an interesting history in that the primary supporters of it have changed several times. PostgreSQL has weathered them all with grace, and remains today an excellent database package with a good, active community and quality developers.

    So, I don't worry about JDBC, I don't write to cross platform, I could give a whit about Oracle or DB2 or whatever, but I don't. PostgreSQL is free, plenty good enough, and it won't go away.

    Why bother trying to make my application portable?

    PS: The article's example about null is stupid. Null = "I don't know". In that context, how could you include values of " 47" if you don't know what the value should be for a particular record?

    I'm interested in this new DB language, if it actually offers a real benefit - but the article does a lousy job of getting me excited about it...

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
    1. Re:Vendor Lock-in is a myth for me by kpharmer · · Score: 2, Insightful

      > Basically, if you have to mentally add an implicit "AND X IS NOT NULL" to every condition, wouldn't it be better to make everything explicit and clear instead?

      The wacky part is using NULLs as a primary excuse to develop another language. First off - NULLs are optional in relational databases. Don't like them? Fine, don't use them. declare your columns 'NOT NULL'. It's that easy.

      Secondly, most work-arounds for unknown data suck:

      * The easy ones involve keeping an 'unknown' value row in most of your tables. That works great - except for high cardinality columns that aren't lookups - like monetary fields, etc.

      * the more common easy work-around is to reserve some value as NULL (2000/01/01 for a date, -1 for an integer column, 'n/a' for a varchar, etc). This really sucks - not only do you have to exclude this from your queries, but you need to know exactly what value to check for, and it's very likely that you'll need a variety of values for each type.

      * the approach I've seen most often by the more skilled of the anti-null crowd involves the creation of more tables - in order to isolate the nullable columns onto other tables that have condition rows. That's ok - but it involves an *explosion* in the size & complexity of the data model. There are some benefits - like it may do a better job of explicitely describing the subject process. But the downside - is that we already *denormalize* (prejoin) many tables together for better performance - primarily for reporting & analysis. Of course, the anti-null crowd also believes that denormalization is a sin - and that database vendors could theoretically provide great performance without denormalization. Unfortunately, their supporting analysis is based upon transactional rather than analytic systems. Ultimately, this approach looks like something that was baked up by people who might work on database software, but don't actually build real-world systems using it.

  51. alternatives by fionbio · · Score: 2, Interesting

    Lisps allow usage of SQL-like syntax inside programs without stuff like "SELECT X FROM Y WHERE Z = ? ORDER BY A" or "SELECT X FROM Y WHERE Z = '" + something + "' ORDER BY A". Look here and here.

    1. Re:alternatives by fionbio · · Score: 2

      BTW, I think this is much better than Embedded SQL which makes programs look like mess (for those who don't think that Lisp programs are mess anyway :), and can be used together with Lisp macros.

  52. OODBs versus RDBs by Tablizer · · Score: 2, Interesting

    Maybe try an object-oriented database....Relational databases aren't the only game in town

    Object DB's don't have enough solid theory behind them. There is too much inconsistency and lack of consensus in the attempts to formalize them.

    It may be because one man, Dr. Codd, created relational theory, and thus there is a narrow set of principles to follow. OO has yet to find a Great Consolidator of similar caliber. (I am skeptical it will happen, but won't rule it out.)

    OO-DB's tend to resemble the type of systems that Dr. Codd was actually trying to "fix" when he came up with relational theory. Thus, OO-DB's tend to seem "primitive" to relational fans.

    Part of the problem is that database themselves run counter to "pure" OO encapsulation. Encapsulation dictates and/or allows each entity to define and handle its own operations. This creates at least two problems:

    1. There is no guarentee that the operations will be compatible or consistent across classes. One class might have a Find operation, but another call it Search, for example.

    2. Encapsulation requires that a single entity (class) handle its own implimentation. However, automated optimization requires the implementation be consistent and known to something outside the entity. In other words, implementation efficiency coordination breaks encapsulation. Objects can't be selfish about their implementation.

    Attempts to solve these tend to make it turn into relational in the end anyhow, making it seem futile to keep OO-ness.

  53. Tutorial D has already been done.. Alphora by sb68 · · Score: 2

    Tutorial D with a truly relational rdbms has already been implemented. The company is Alphora. The product is Dataphor. see http://www.alphora.com/

  54. If you're sensible, you're never touching raw SQL by Julian+Morrison · · Score: 4, Informative

    Talking SQL nowadays strikes me as being like talking raw assembler. You can do it, the tools are even rather nice nowadays, but any sane developer would use a higher level wrapper.

    Like for instance, Hibernate. It does serialize/reconstitute, handles nested objects and data structures, and it's very nearly as easy as programming with regular heap-allocated objects. In any big app if you didn't use some such, you'd end up reimplementing it.

    I see no reason wrappers like Hibernate have to backend onto SQL and only SQL. They could as easily emit and control this "Tutorial D" language.

  55. Re:Theory and practice by insac · · Score: 2, Interesting

    > Usually, IMO, performance tuning, when it requires altering the storage schema, is done using one of two methods: > 1) Denormalization > 2) Higher normal forms > 3) Summary tables I agree with you if you mean that these are the tricks the (optimal) RDBMS could use "under the cover" to optimize the access plan (making them "transparent" to the application). Let's take the "Denormalization" as an example: we have two entities A and B that are loaded once a day with a batch. We know that they're mostly joined together in the queries. My idea of an "optimal" RDBMS is that I can define the two entities and the application can query them individually or joined together. Then I decide to start the "tuning" phase and I give the RDBMS an "hint" to change the physical layout of the data and keep them just in a single "data store". I keep inserting tuple in A,B entities and the RDBMS would keep the "abstraction" of two indipendent entities. The joined query (that is the more frequent) can get the data from the 2 entities from the same blocks. If the application evolves in a way that the individual queries become more frequent I'd have to "revoke" the hint and separate the datastores WITHOUT changing the application. The SQL RDBMS are beginning to have these features (what I describe here is more or less the Oracle CLUSTERED TABLE) but on other databases the solution is to change the logical schema when they just want to change the phisical layout of the data.

    --
    This message doesn't need a sig