• (cs)
    Andy:
    For the database unacquainted, having an identifier in a table that’s the result of another identifier divided by 10,000,000 is just sick.

    How about 1,000,000? It that OK?

  • (cs)

    0.000001st

  • (cs)

    At first glance it may seem sick, but it's possible that the application code has a relationship where thing2.id = thing1.id * 1000000 (semi-analgous to dates stored like: year10000+month100+day), and so they propagated that into the db relationships instead of mapping it properly.

    I'm not saying it's a good thing to do, but I've seen it done.

  • (cs)

    I feel like my brain just exploded into 1,000,000 pieces.

  • dave (unregistered)

    Looks to me like they use order IDs on the form XXXXXXYYYYYY where XXXXXX is the customer ID and YYYYYY is a squence number. Yes, it could have made sense to split this up into two columns in the database, but this method works just as fine for finding orders for a customer.

  • Ben (unregistered)

    It's generally a bad idea to store two values as one, since it makes them unavailable to relational operators. But, really, SQL itself is such a mess that the right way of doing things becomes a hassle.

    And the reality is that many identifiers (phone numbers, SSNs, VINs, MAC addresses) are really composites of smaller identifiers, so you're often stuck.

    Keep in mind that in SQL, to join on a compound key requires the following every time you join:

    FROM A INNER JOIN B ON A.col1 = B.col1 and A.col2 = B.col2

    (Yes, you can use NATURAL JOIN iff the column names match.)

    It's not all that bad, but a lot of people do avoid it, and some other tasks become a little more complicated. So normally you wind up with surrogate keys all over the place and your system is littered with useless, unreadable surrogate IDs. In this case, I don't think it's so awful to load two numbers into one by means of simple arithmetic.

  • Billy The Squid (unregistered)

    Autoincrement by whole numbers is for chumps. I want my ID incrementing by 0.0000001!

    For my next table, it's going to increment by number of sunday's since the epoch.

  • Zapp Brannigan (unregistered) in reply to frits
    frits:
    Andy:
    For the database unacquainted, having an identifier in a table that’s the result of another identifier divided by 10,000,000 is just sick.

    How about 1,000,000? It that OK?

    I'm not sure, it's either 10 times better or 10 times worse.

  • Slicerwizard (unregistered) in reply to frits
    frits:
    Andy:
    For the database unacquainted, having an identifier in a table that’s the result of another identifier divided by 10,000,000 is just sick.

    How about 1,000,000? It that OK?

    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

  • Anonymous (unregistered) in reply to Slicerwizard
    Slicerwizard:
    frits:
    Andy:
    For the database unacquainted, having an identifier in a table that’s the result of another identifier divided by 10,000,000 is just sick.

    How about 1,000,000? It that OK?

    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

    I'm sure things are much better on your technology blog.

  • Knux2 (unregistered)

    The requirements were "All ShipToCustomerIds must be evenly divisible by 1000000." They're just saving space in the database!

  • Osno (unregistered)

    Not only sick, also slow. That query doesn't use indexes and in the case of Sql Server you will have to recompile stored procedures on each use because of that.

  • remi (unregistered)

    I did something like this a few month ago : I needed some row to appear in a query but I didn't want to had a field to my table and my class to be able to distinct them from the others, so their ids begin at 10000 :)

    It's like tetris,it's ugly but it's really fun.

  • Protector one (unregistered)

    Hey... if it works...! :D All is fair, in Love and SQL.

    (Captcha: "dignissim", what I'd like to think is Jiddish for "dagnabbit".)

  • (cs)

    It's not sick, it's genius! Just multiply two integers together and store the result to save space!

    Huh. I wonder why customer 3's second order is exactly the same as customer 2's third order?

  • Jason (unregistered) in reply to Anonymous

    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong. Similarly, I'm not a tech blogger, but I can see that Alex often makes errors that would be caught if he re-read his posts with a critical eye --- that is, he's doing it wrong.

  • (cs) in reply to remi
    remi:
    I did something like this a few month ago : I needed some row to appear in a query but I didn't want to had a field to my table and my class to be able to distinct them from the others, so their ids begin at 10000 :)

    ಠ_ಠ

  • PITA (unregistered) in reply to remi
    remi:
    I did something like this a few month ago : I needed some row to appear in a query but I didn't want to had a field to my table and my class to be able to distinct them from the others, so their ids begin at 10000 :)
    FAIL!
  • Anon (unregistered) in reply to Jason
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong. Similarly, I'm not a tech blogger, but I can see that Alex often makes errors that would be caught if he re-read his posts with a critical eye --- that is, he's doing it wrong.

    QFT! I really hate the "yeah, let's see you do better" comeback. Steve Jobs pulled that on an iPad critic the other day and it's weak. Just because I can't (or don't want to) do X doesn't mean I can see the problems when somebody else does X. And if you don't like this comment, let's see you do better.

  • jrh (unregistered) in reply to Ben
    Ben:
    It's generally a bad idea to store two values as one, since it makes them unavailable to relational operators. But, really, SQL itself is such a mess that the right way of doing things becomes a hassle.

    And the reality is that many identifiers (phone numbers, SSNs, VINs, MAC addresses) are really composites of smaller identifiers, so you're often stuck.

    Keep in mind that in SQL, to join on a compound key requires the following every time you join:

    FROM A INNER JOIN B ON A.col1 = B.col1 and A.col2 = B.col2

    (Yes, you can use NATURAL JOIN iff the column names match.)

    It's not all that bad, but a lot of people do avoid it, and some other tasks become a little more complicated. So normally you wind up with surrogate keys all over the place and your system is littered with useless, unreadable surrogate IDs. In this case, I don't think it's so awful to load two numbers into one by means of simple arithmetic.

    Ben, I'm going to give you the benefit of the doubt and assume you are a good developer outside of SQL.

    But why do otherwise decent developers throw out good practice when they get to the database? Would you have a class where the CustomerID and the OrderID are stored in the same property and leave it up to the class user to pick the two apart? If you have a compound key you, you need to either use a compound key or a surrogate key.

    As for your theory that it's not "so awful to load two number into one by means of simple arithmetic", well I guess that's true as long as you don't need your database to scale in any way.

  • airdrik (unregistered)

    Well it's obvious that since everything gets stored as integers, we might as well encode all of our attributes into the integer ID column. Everything with ID greater than 1000000 has a customer associated with it, grouped by 1000000's (so, to make things convenient, 1000000-1999999 are associated with customer ID 1, 2000000-29999999 with customer ID 2, etc.). Then if the ID is divisible by 3 then it is the invoice for a sale, sale ID + 1 is a returned item, sale ID + 2 is reserved for special cases and extra storage if necessary. If the sum of the digits is 10, then it was a sale of a TV, sum = 11 is sale of camara, sum = 12 is the sale of a digital storage device, ... The quantity is encoded as the ID mod 200 (because nobody will ever need to buy more than 200 of anything)

    This way we can save storage by reducing the columns that we need to store and just using carefully constructed IDs.

    "I'm sorry, but our invoicing system is unable to determine an appropriate ID for your order. Do you want to:

    • select a different quantity
    • select a different brand
    • cancel your order ..."

    Captcha: iusto - I iusto rite gud cood, entil I startd wreeding TDWTF.

  • Hugo (unregistered)

    Ouch.

    And what about SQL Server's Unique Identifier type? Try porting that logic over to any other database... :P

  • (cs) in reply to Anon
    Anon:
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong. Similarly, I'm not a tech blogger, but I can see that Alex often makes errors that would be caught if he re-read his posts with a critical eye --- that is, he's doing it wrong.

    QFT! I really hate the "yeah, let's see you do better" comeback. Steve Jobs pulled that on an iPad critic the other day and it's weak. Just because I can't (or don't want to) do X doesn't mean I can see the problems when somebody else does X. And if you don't like this comment, let's see you do better.

    Don't blame Alex. He just can't be stronger than fate itself : TDWTF is truly bound to the doom of Muphry's law... (not it's not a typo)(yes, it has already be quoted in other TDWTF posts)(maybe I'm just loving parenthesis)

  • grknight (unregistered)

    Why not divide by 1.21 gigawatts for a time machine?

  • Anonymous (unregistered) in reply to Jason
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong.
    How can you possibly say that? From your position of "absolutely clueless" you cannot possibly make the assertion that "you're doing it wrong". There may be environmental factors at play, there may be any number of external influences that you simply don't understand so you are in no place to judge. I actually think your basic point is OK but your example was absolutely retarded! "Hurr durr, you plane no fly, you doing it wrong, hurr durr!!!".
  • Bruce W (unregistered) in reply to Slicerwizard
    Slicerwizard:
    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

    Or Alex could be intentionally leaving in the typos just to drive the Grammar Nazis insane.

  • Max (unregistered) in reply to Anonymous
    Anonymous:
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong.
    How can you possibly say that? From your position of "absolutely clueless" you cannot possibly make the assertion that "you're doing it wrong". There may be environmental factors at play, there may be any number of external influences that you simply don't understand so you are in no place to judge. I actually think your basic point is OK but your example was absolutely retarded! "Hurr durr, you plane no fly, you doing it wrong, hurr durr!!!".
    I think the example is just fine. He doesn't know the details of airplane design, but he knows the definition of an airplane encompasses machines that fly. If someone tells him they have an airplane, but upon demonstration it fails to fly, he knows something is wrong. Whether the "doing it wrong" is inherent to the design (insufficient thrust, excessive drag, excessive weight, etc.), due to pilot error (not pushing the throttle enough, pushing down instead of pulling up because he doesn't invert the pitch when he plays video games, etc.), or due to some external factor (strong crosswind, improperly maintained runway, etc. - all of which should be checked before flight anyways), he can still see that something is wrong. Likewise, when there is a typo in TDWTF, there's no knowing if it was in the original version, added when posting, or a result of a cat jumping on the keyboard. Regardless, it's something that ought to be checked before being posted. In the end, some errors will still make it through, just like some planes will fail to take off for one reason or another, however the occurrence should be reasonably small.
  • Anon (unregistered) in reply to Anonymous
    Anonymous:
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong.
    How can you possibly say that? From your position of "absolutely clueless" you cannot possibly make the assertion that "you're doing it wrong". There may be environmental factors at play, there may be any number of external influences that you simply don't understand so you are in no place to judge. I actually think your basic point is OK but your example was absolutely retarded! "Hurr durr, you plane no fly, you doing it wrong, hurr durr!!!".

    Well, if the plane doesn't fly, even with no knowledge of aeronautics, I think it's fair to say they're doing it wrong. A plane is supposed to fly or it's not a plane. A plane that can't fly can rightly be criticized. You'd have a point if it's not that it can't fly at all, but that it can't fly in this particular set of conditions (say a volcanic cloud of ash hovering overhead). It's not the best example, but let's see you do better!

    A better example would be to say that you can't criticize Uwe Boll movie unless you've made your own big budget movie based on a video game and inexplicably managed to get big name stars to sign up for it. Therefore, nobody's allowed to say Alone in the Dark was total shit. Another example would be, you can't criticize the president unless you've been president of the US.

  • Anonymous (unregistered) in reply to Anon
    Anon:
    You'd have a point if it's not that it can't fly at all, but that it can't fly in this particular set of conditions (say a volcanic cloud of ash hovering overhead). It's not the best example, but let's see you do better!
    GOD'S doing it wrong! Screw you God, you fail (hurr durr)!
  • Steve-O (unregistered) in reply to Anonymous
    Anonymous:
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong.
    How can you possibly say that? From your position of "absolutely clueless" you cannot possibly make the assertion that "you're doing it wrong". There may be environmental factors at play, there may be any number of external influences that you simply don't understand so you are in no place to judge. I actually think your basic point is OK but your example was absolutely retarded! "Hurr durr, you plane no fly, you doing it wrong, hurr durr!!!".

    Remember that the next time you watch a sporting event. Thinking of that... why do we have coaches at all? They're not any better than the players; how could they possibly tell a player that they're doing it wrong.

  • Ethan Qix (unregistered) in reply to Bruce W
    Bruce W:
    Slicerwizard:
    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

    Or Alex could be intentionally leaving in the typos just to drive the Grammar Nazis insane.

    Or Alex is merely human and thus prone to mistakes, like the rest of us. You don't call that TRWTF.

  • Anonymously Yours (unregistered)

    Amateur. My single table database can store anything and has its customer records on a modulus of 17.

  • Peter (unregistered) in reply to Bruce W
    Bruce W:
    Or Alex could be intentionally leaving in the typos just to drive the Grammar Nazis insane.
    The error that sparked off this particular round of arguments was a factor of 10 discrepancy between a number in the code and a number in the description. Grammar Nazis should be completely indifferent to that.
  • (cs)

    It is times like this that I wish I had a machinegun.

  • (cs) in reply to Anonymous
    Anonymous:
    Jason:
    The attitude that you can't criticize someone unless you can do better is senseless. I'm not an aeronautical engineer, but I can still see that someone whose airplane won't take off is doing it wrong.
    How can you possibly say that? From your position of "absolutely clueless" you cannot possibly make the assertion that "you're doing it wrong". There may be environmental factors at play, there may be any number of external influences that you simply don't understand so you are in no place to judge. I actually think your basic point is OK but your example was absolutely retarded! "Hurr durr, you plane no fly, you doing it wrong, hurr durr!!!".
    If his position was indeed "absolutely clueless" then you would be correct. If I am "absolutely clueless" about how a device is made, how it works, or what its successful conditions are, then I really can't criticize the maker for "doing it wrong." However, in this case, he is not "absolutely clueless." He, like all of us, understands the basic premises of an airplane.

    The same concept can be applied to this site. We understand the basic premises of running a website/blog and of the English language and are therefore able to see that it is indeed "done wrong."

    Further, even if the "do it better" argument was valid, I think that by submitting corrections the users are, in fact, doing it better. The complaint is not about the site, its design, or its content. It is about the grammar and spelling of the articles, everything else is secondary to this debate/argument.

    (Note: That being said, I am not a grammar nazi. I generally just ignore any mistakes I see. However, I am a logic nerd and will freely point out glaring errors in applying basic logical reasoning to a situation that I come across.)

  • Arthur D (unregistered)

    No, everybody, please, continue to comment on things that you don't understand. You add to the entertainment value of this site.

  • (cs) in reply to Anonymously Yours
    Anonymously Yours:
    Amateur. My single table database can store anything and has its customer records on a modulus of 17.

    You kid, but I've worked with something like this.

    My second job was at a medical software company (1991 or so). The frequently-used database tables were optimized around the limitations of the programming language/database (which originated in the late 60's or early 70's and whose name is synonymous with a childhood disease) and the disk storage system.

    I remember one table specifically - it was a data dictionary, and the original programmers (also in the early 70's, I believe) had determined that storing the primary key (DE, for Dictionary Entry) as two values - DE DIV 23 and DE MOD 23 - would provide the most efficient access.

    When I got there, the technology had progressed far beyond needing such things, but like most legacy systems, it hadn't been changed.

  • Jay (unregistered) in reply to Anonymous
    Anonymous:
    Anon:
    You'd have a point if it's not that it can't fly at all, but that it can't fly in this particular set of conditions (say a volcanic cloud of ash hovering overhead). It's not the best example, but let's see you do better!
    GOD'S doing it wrong! Screw you God, you fail (hurr durr)!

    Unless God's goal is to prevent that particular airplane from taking off, in which case:

    1. Observe plane attempting to take off
    2. Determine that this is not in accordance with Your long-range plan for the universe
    3. Ignite volcano to prevent plane from taking off
    4. Profit! (Or in this case, Prophet!)
  • Jay (unregistered) in reply to Ethan Qix
    Ethan Qix:
    Bruce W:
    Slicerwizard:
    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

    Or Alex could be intentionally leaving in the typos just to drive the Grammar Nazis insane.

    Or Alex is merely human and thus prone to mistakes, like the rest of us. You don't call that TRWTF.

    And I'll get out on a limb here, but I think incorrectly copying a number in a humorous story is somewhat less important in the grand scheme of things than an airplane falling out of the sky and killing all the passengers on board. Perhaps Alex doesn't care very much about an occasional grammar error or typo because he does not suffer from obsessive-compulsive disorder.

  • (cs) in reply to grknight
    grknight:
    Why not divide by 1.21 gigawatts for a time machine?

    1.21 gigawatts? The only thing that can produce 1.21 gigawatts is a bolt of lightning! I hope you've got a really good surge protector on your server.

  • mike (unregistered)

    A millionth of a customer is still a customer. Just a very small one.

    (I never do this but, well..) Captcha: aptent - a poorly constructed application server.

  • Someone like Kevin (unregistered) in reply to Anonymous
    Anonymous:
    Anon:
    You'd have a point if it's not that it can't fly at all, but that it can't fly in this particular set of conditions (say a volcanic cloud of ash hovering overhead). It's not the best example, but let's see you do better!
    GOD'S doing it wrong! Screw you God, you fail (hurr durr)!
    Geology fail.
  • (cs) in reply to Arthur D
    Arthur D:
    No, everybody, please, continue to comment on things that you don't understand. You add to the entertainment value of this site.

    Cointently! Nyuck Nyuck!

  • a (unregistered)

    I can't believe you idiots spend this much time arguing over typos. This is ridiculous. Typos are not "the real WTF", "the real WTF" is that anyone gives a shit. It's a blog, not his job, it doesn't have to be perfect. Stop wasting your time and ours.

  • EngleBart (unregistered)

    How are they going to have a big party for the millionth customer? Sorry, you would have been the millionth customer, but we overflowed your id back to zero, so the original customer zero is receiving your order and your prize.

    P.S. Customer 0 is the special back door customer id that gives you administrative privileges on the site. Planned rather well I would say...

  • Someone like Kevin (unregistered) in reply to Jay
    Jay:
    Ethan Qix:
    Bruce W:
    Slicerwizard:
    If this site teaches us anything, it's that Alex has a major problem with attention to detail.

    And before anyone blames this on the submitter, how do you know that the original submission had the error? Besides, an editor is supposed to catch stuff like this. AKA TRWTF.

    Or Alex could be intentionally leaving in the typos just to drive the Grammar Nazis insane.

    Which is less important than an asteroid splitting the earth. So now no one can comment on anything that isn't at least as bad as total planetary destruction.

    Or Alex is merely human and thus prone to mistakes, like the rest of us. You don't call that TRWTF.

    And I'll get out on a limb here, but I think incorrectly copying a number in a humorous story is somewhat less important in the grand scheme of things than an airplane falling out of the sky and killing all the passengers on board. Perhaps Alex doesn't care very much about an occasional grammar error or typo because he does not suffer from obsessive-compulsive disorder.

  • JoeKu (unregistered)

    I really don't think this is in WTF territory (it isn't good, but I have encountered reasons to do so [curse the stupid middle-tier]). It is obvious that the db requires each table to have non-composite primary key. This is probably because of the limitation imposed by the middle-tier. If the business requirement states that a single "cui" can never have more than 1 million distinct "ShipToCustomer" (i.e. 1000 addresses), then this is one way of skinning the problem. [Yes, I did say it's not ideal as you can use a segregate key in a associate table, this will eliminate a table.]

    co is obviously the Company table, and cu is the Customer table. I guess cui is "ShipToCustomer" which is CustomerAddress table.

    I have seen "object-oriented db" design (i.e. 1 lookup table). I have seen "design" with duplicate facts across 3 dbs and 2 servers, handling 200 orders and require 200GB DASD. This is no way in the level of WTF.

  • Владмир (unregistered) in reply to RogerC
    RogerC:
    I feel like my brain just exploded into 1,000,000 pieces.
    Mine exploded into 10,000,000 pieces.
  • kikito (unregistered)

    I want to meet the consultant that programmed this.

  • Kerbleckistan4Life (unregistered)

    maybe I needing later

Leave a comment on “The Quotient ID”

Log In or post as a guest

Replying to comment #:

« Return to Article