Just curious, what are your SQL pet peeves ?

  • Koen Verbeeck (6/6/2014)


    gbritton1 (6/6/2014)


    Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Technically? Not sure what that means. Division by zero is undefined in ordinary arithmetic and has no meaning.

    Technically means looking at mathematical theory.

    It is not undefined.

    If you take y:= f(x) = 1 /x and you plot it out on a graph, you can clearly see that for x going to 0 y is going to infinity.

    So you can say that in the asymptote of x->0, y equals infinity.

    I have fair amount of University-level mathematics and understand theory reasonably well if not at an expert level. However, I was talking about ordinary arithmetic, not limits. In ordinary arithmetic, x/0 is most certainly undefined. If we're talking about limits, the best you can say is as x approaches 0, y approaches infinity. If x every reaches 0, the result is still undefined.

  • djj (6/6/2014)


    One thing I do not like is people calling tables, databases. I can understand calling a column a field but it still gets me thinking.

    I run into something similar all the time...

    I think it comes from most of the people here worked with the previous DBA, who was more Oracle than MS SQL, where in Oracle:

    Oracle Database ~= MS SQL Server

    Oracle Schema ~= MS SQL Database

    Drives me nuts in conversations having to translate in my head...

  • djj (6/6/2014)


    An expert converted our database from Access to SQL2000. We now have zip codes that are float, column names with spaces and #.

    One thing I do not like is people calling tables, databases. I can understand calling a column a field but it still gets me thinking.

    Given much of our code is pre semicolon, putting one before the WITH saves me thinking about putting on after the last statement. I am trying to break the habit but get lazy.:-)

    That's why I consider zip codes, phone numbers, credit card numbers & others should be stored on string type columns. You could enforce to use just digits (or other characters) with CHECK CONSTRAINTS.

    The reason behind this is because those values won't behave as a number. You won't use any arithmetic operations on them.

    I like to use plurals on table names but not on column names. So you would have table Orders and column OrderID, OrderDate, etc.

    And I hate a table at my current job with a structure like this:

    CREATE TABLE AMB60RESCARDEL(

    AM001 date,

    AM002 char(8),

    AM003 char(10),

    --...

    AM150 char(15))

    And I'm not obfuscating the names. :crazy:

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Koen Verbeeck (6/6/2014)


    gbritton1 (6/6/2014)


    Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Technically? Not sure what that means. Division by zero is undefined in ordinary arithmetic and has no meaning.

    Technically means looking at mathematical theory.

    It is not undefined.

    If you take y:= f(x) = 1 /x and you plot it out on a graph, you can clearly see that for x going to 0 y is going to infinity.

    So you can say that in the asymptote of x->0, y equals infinity.

    That would be the equivalent of a triangle where two corners are 90°

    😎

  • Luis Cazares (6/6/2014)

    That's why I consider zip codes, phone numbers, credit card numbers & others should be stored on string type columns. You could enforce to use just digits (or other characters) with CHECK CONSTRAINTS.

    The reason behind this is because those values won't behave as a number. You won't use any arithmetic operations on them.

    You know that and I know that but the "expert" did not. They were not smart enough to question what Microsoft was doing.

  • Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Wel, I reckon you can't. But the amusing thing is that model-theoretic models of various classes of numbers (natural numbers, integers, rationals, reals, complex numbers, etcetera ad nauseam) can easily be built to include infinite numbers (this is a consequence of the Lowenheim-Skolem theorem for predicate calculus) but in none of those models is divide by 0 possible.

    Where your approach breaks down is that there's not one asymptote, there are two different ones. The nonexistent* limit as you approach 0 from below is a different infinity from the nonexistent limit as you approach zero from above. And you can't pretend they are both the same infinity, or all sorts of well understood proerties of convergence and limits break down, and things quickly lead to infinity = 0 and then to all numbers = 0. So you can't divide a number by zero if your maths has both positive and negative numbers.

    *: Nonexistent above is meant literally - if you claim the limits exist then you claiming that a large class of divergent series are convergent - but if you are talking about asymptotes rather than limits then even if you don't claim that they are numbers you have two of them, which don't intersect and are never even very close to each other, and division being a single-valued function is not an idea you should want to discard - in fact even discarding the rule that the result of division, when division is possible, is a number is already weird beyond acceptability, I reckon.

    Perhaps you can divide by zero if you are working with only zero and positive numbers (or only zero and negative numbers if you prefer) and manage to define an infinity that behaves itself, is a number like the others. I don't reaaly think that's actually possible, though: either you discard the cancellation properties of addition and subtraction: (A-B) = (A-C) no longer implies B = C, nor does (A+B) = (A+C) imply B = C, or that cancellation still works and all numbers are equal to 0. Or the cancellation property doesn't apply if A is infinity so infinity doesn't behave at all like a number. Maybe you could emilate the IEEE floating point standard and declare that infinity is not a number but that means it can't be a limit of a numerical function - and that's the safest way to go, I believe, if you want to do something like this; but then what you are doing certainly isn't division, it doesn't even have the connection with division that playing with that non-existent that limit has.

    Tom

  • djj (6/6/2014)


    Luis Cazares (6/6/2014)

    That's why I consider zip codes, phone numbers, credit card numbers & others should be stored on string type columns. You could enforce to use just digits (or other characters) with CHECK CONSTRAINTS.

    The reason behind this is because those values won't behave as a number. You won't use any arithmetic operations on them.

    You know that and I know that but the "expert" did not. They were not smart enough to question what Microsoft was doing.

    I wonder if there's a definition of "expert" of which we're not aware about.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • OK, if you folks don't knock it off with the divide by 0 discussion, I'm going to execute DBCC TIMEWARP (GETDATE()/0)!!!

    Then we'll see what happens when you divide by 0!

    :hehe:

  • TomThomson (6/6/2014)


    Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Unfortunately there's not one asymptote, there are two different ones. The limit as you approach 0 from below is a different infinity from the limit as you approach zero from above. And you can't pretend they are both the same infinity, or all sorts of well understood proerties of convergence and limits break down, and things quickly lead to infinity = 0 and then to all numbers = 0. So you can't divide a number by zero if your maths has both positive and negative numbers.

    Perhaps you can divide by zero if you are working with only zero and positive numbers (or only zero and negative numbers if you prefer) and manage to define an infinity that behaves itself, is a number like the others. I don't think that's actually possible, though: either you discard the cancellation properties of addition and subtraction: (A-B) = (A-C) no longer implies B = C, nor does (A+B) = (A+C) imply B = C, or that cancellation still works and all numbers are equal to 0. Or the cancellation property doesn't apply if A is infinity so infinity doesn't behave at all like a number. Maybe you could emilate the IEEE floating point standard and declare that infinity is not a number but that means it can't be a limit of a numerical function - and that's the safest way to go, I believe, if you want to do something like this; but then what you are doing certainly isn't division, it doesn't even have the connection with division that playing with that non-existent that limit has.

    I had a TI calculator in the old days which would accept a divisor of zero value, I also had a good maths foundation which tough me the meaning of "no quantity or number; nought; the figure 0". Zero division is equal to NULL comparison!

    😎

  • Eirikur Eiriksson (6/6/2014)


    Koen Verbeeck (6/6/2014)


    gbritton1 (6/6/2014)


    Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Technically? Not sure what that means. Division by zero is undefined in ordinary arithmetic and has no meaning.

    Technically means looking at mathematical theory.

    It is not undefined.

    If you take y:= f(x) = 1 /x and you plot it out on a graph, you can clearly see that for x going to 0 y is going to infinity.

    So you can say that in the asymptote of x->0, y equals infinity.

    That would be the equivalent of a triangle where two corners are 90°

    😎

    Valid on a sphere where all three angles can be 90 degrees!

    Gerald Britton, Pluralsight courses

  • Luis Cazares (6/6/2014)


    djj (6/6/2014)


    Luis Cazares (6/6/2014)

    That's why I consider zip codes, phone numbers, credit card numbers & others should be stored on string type columns. You could enforce to use just digits (or other characters) with CHECK CONSTRAINTS.

    The reason behind this is because those values won't behave as a number. You won't use any arithmetic operations on them.

    You know that and I know that but the "expert" did not. They were not smart enough to question what Microsoft was doing.

    I wonder if there's a definition of "expert" of which we're not aware about.

    That is what I would call smart design. After all, leading zeros matter in zip codes. Here in the US, we have five-digit zip codes, but there's some systems in the world that have longer ones and some include alphabetic characters. Plus the reasons you stated above. Again, it comes down to design.

  • g.britton (6/6/2014)


    Eirikur Eiriksson (6/6/2014)


    Koen Verbeeck (6/6/2014)


    gbritton1 (6/6/2014)


    Koen Verbeeck (6/6/2014)


    TomThomson (6/6/2014)


    Just a couple of examples: A British colleague who held an A-level in math and a bachelor's in business swore you could, in fact, divide a number by zero and that my calculator must be wrong when I proved to him that you couldn't. He wouldn't take my word for it because according to him, "Americans are bad at maths."

    OK, he was an idiot. No-one claims that there are no British idiots.

    Technically, you can divide a number by zero. In its asymptote it approaches infinity, so you can baldly say that dividing a number through zero equals infinity. Calculators are just dumb things that can't display infinity, can you believe that?

    Technically? Not sure what that means. Division by zero is undefined in ordinary arithmetic and has no meaning.

    Technically means looking at mathematical theory.

    It is not undefined.

    If you take y:= f(x) = 1 /x and you plot it out on a graph, you can clearly see that for x going to 0 y is going to infinity.

    So you can say that in the asymptote of x->0, y equals infinity.

    That would be the equivalent of a triangle where two corners are 90°

    😎

    Valid on a sphere where all three angles can be 90 degrees!

    Not on the same plane (euclidean plane), as much as I like this comment, to me this is cheating:-P

    😎

  • Luis Cazares (6/6/2014)


    djj (6/6/2014)


    An expert converted our database from Access to SQL2000. We now have zip codes that are float, column names with spaces and #.

    That's why I consider zip codes, phone numbers, credit card numbers & others should be stored on string type columns.

    I was teaching DB design to my company's devs couple weeks ago. My comment to them was "If you're not going to add, subtract, multiply, divide, square root, take the modulus, invert, negate or raise to a power, it's probably not a number." Most of them laughed. A couple came by later in the week asking about how to alter a column's type and find all dependencies.

    p.s. Thanks for the topic. 🙂

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Just because I want to see DBTIMEWARP get used:

    The number line is not a line, it's a circle, proven by the Divide by 0 asymptote. You just have to flip the page over to find the answer, it's on the back. 😉


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • SQL is delicious (6/6/2014)


    I'm not intending to slag off the British, I don't want anyone to get that impression.

    I don't see how anyone could interpret your previous post as having any such intent. Certinly I didn't.

    I also defend the UK's food on a regular basis...oddly, it's what I miss most about it! I miss milk, eggs, bread, meat, etc. that taste like actual milk, eggs, bread, and meat. I think we are in complete agreement that there are idiots in both countries, and brilliant minds in both countries. Most people fall somewhere in-between. I consider myself part of the in-between, closer to "brilliant" than "idiot." 🙂

    Yes, we're in complete agreement.

    Regarding Mensa, I didn't actually join in the UK or the USA. I was having a crisis of confidence in myself at the time, so I took the test at my ex-husband's urging. He felt that I would do well enough to be invited to join and that it would give my confidence a boost. He was right on both counts. I had no desire to be a member of Mensa. And I know a lot of IQ testing is subjective, racially-biased, and a bit meaningless. But still, it felt nice to see my score and percentile in black and white. I won't lie. 🙂

    That's something I hadn't thought of - using the Mensa test to boost confidence and morale. So Mensa is actually useful for something after all! NAd you don't even have to join to get the use! I will think better of Mensa after seeing that than I did before.

    I was probably saved from needing some sort of confidence boost about inelligence by my wife: she bought a collection of graded tests and insisted that we used them as a game - on each test, whoever got the better score won. Since we were both scoring consistently higher than we had expected it stopped us worrying.

    As for my own education...I went to the University of Texas at Austin, one of the U.S.'s "public ivies" and the top public university in my state, both then and now. Admittedly, it was easier to get in 20 years ago than it is now. 😉 I came out the other end four years later with a bachelor's degree in a liberal arts discipline. I don't "use" my degree in my career, but few people do. What my liberal arts education gave me was open-mindedness, resourcefulness, a love of learning, and a degree of intellectual flexibility that allows me to take what I've learned in one area and apply it to another.

    Then you got more out of your education than most people do - I am convinced that the important things that education gives anyone are the ability to learn and to apply one's efforts to learning, to be open-minded, and to understand how to use one's knowledge and experience to tackle new things. specific subject knowledge is less important than those (but if you have them early enough in the coutrse you'll have no problems with the specific subject stuff).

    I focused on languages and applied linguistics and thoroughly enjoyed being a student. I studied what I loved. I didn't even know what a database was when I was a student. I don't regret it. 🙂 However, I wouldn't recommend it to someone nowadays wanting to enter the I.T. field. The landscape has changed, and employers are much more picky about qualifications than they were when I entered the field in the late 1990s.

    Languages and linguistics - that was one of the two options I seriously considered for university, but I picked the other (Maths). And then I used languages far more in my career that I've used maths. My wife's subject (before we met) was Theology, which meant we had sufficiently different knowledge to keep each other interested - it still works today. There used to be hordes of people with non-science non-engineering degrees who worked in computing/IT, in fact of people with all sorts of arts degrees or no degrees at all, and no-one who was around in computing in the early days though a degree in computing or IT was needed and they were right - where would IT have got to without Turing, Wilkes, Perlis, Scott, Hoare, Codd, Milner just to name a few. If IBM had wanted people with IT traiing, Codd wouldn't have worked there and perhaps he wouldn't have conceived teh Relational Database. That just about everyone today wants to recruit only IT or CS degree holders probably means we are missing some of the best possible people to employ in computing.

    When I lived in the UK, I lived in a uni city where one of the country's top universities was located. It was always in the top five unis in the country, sometimes in the top three. Most of the people I was friends with were affiliated with the uni in some way or had at least graduated from it. Many held advanced degrees. I know some unis in the UK are dropping the ball, but that particular institution is definitely doing it right. 🙂

    Interesting. Whish town that is depends on dates, I think. Obvioulsy LSE has been number 3 recently more often than anyone else, but London is hardly a university town despite how many universities it has. Was it St Andrews? Or Edinburgh? Or perhaps Warwick, or Durham, or Glasgow, or Bath? Or somewhere else - the league tables vary so much from source to source and from year to year that I can't guess where it was (for example RGU was third in at least one table, I can't remember which year, but I don't remember it being in the top 5 any other year, and Aberdeen's other university has also been pretty high at least once but isn't usually, so the town seems unlikely to be Aberdeen, but of course it could be). Also foreign ratings of UK universities tend to produce a very different order from the UK's own ratings, because they rate on different things. Are you going to name the town (and the U, if the town has more than one)?

    Tom

Viewing 15 posts - 151 through 165 (of 271 total)

You must be logged in to reply to this topic. Login to reply