Comment On The Quotient ID

To say that the codebase at Andy’s client is sub-optimal would be generous. It’s a kludge on top of a kludge that was cobbled together by countless developers over many years. And as with many large and unwieldy information systems, distilling this beast into an understandable form is a challenge superseded only by the actual maintenance of the code. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: The Quotient ID

2010-06-02 09:04 • by 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?

Re: The Quotient ID

2010-06-02 09:07 • by MyKey_
0.000001st

Re: The Quotient ID

2010-06-02 09:08 • by snoofle
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: year*10000+month*100+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.

Re: The Quotient ID

2010-06-02 09:12 • by RogerC
I feel like my brain just exploded into 1,000,000 pieces.

Re: The Quotient ID

2010-06-02 09:14 • by 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.

Re: The Quotient ID

2010-06-02 09:18 • by 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.

Re: The Quotient ID

2010-06-02 09:20 • by 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.

Re: The Quotient ID

2010-06-02 09:28 • by Zapp Brannigan (unregistered)
310219 in reply to 310211
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.

Re: The Quotient ID

2010-06-02 09:32 • by Slicerwizard (unregistered)
310220 in reply to 310211
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.

Re: The Quotient ID

2010-06-02 09:36 • by Anonymous (unregistered)
310221 in reply to 310220
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.

Re: The Quotient ID

2010-06-02 09:36 • by Knux2 (unregistered)
The requirements were "All ShipToCustomerIds must be evenly divisible by 1000000." They're just saving space in the database!

Re: The Quotient ID

2010-06-02 09:48 • by 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.

Re: The Quotient ID

2010-06-02 09:48 • by 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.

Re: The Quotient ID

2010-06-02 09:51 • by 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".)

Re: The Quotient ID

2010-06-02 09:54 • by lolwtf
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?

Re: The Quotient ID

2010-06-02 10:01 • by Jason (unregistered)
310228 in reply to 310221
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.

Re: The Quotient ID

2010-06-02 10:08 • by akatherder
310230 in reply to 310225
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 :)


ಠ_ಠ

Re: The Quotient ID

2010-06-02 10:19 • by PITA (unregistered)
310231 in reply to 310225
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!

Re: The Quotient ID

2010-06-02 10:28 • by Anon (unregistered)
310232 in reply to 310228
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.

Re: The Quotient ID

2010-06-02 10:29 • by jrh (unregistered)
310233 in reply to 310217
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.

Re: The Quotient ID

2010-06-02 10:40 • by 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.

Re: The Quotient ID

2010-06-02 11:02 • by Hugo (unregistered)
Ouch.

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

Re: The Quotient ID

2010-06-02 11:05 • by toshir0
310237 in reply to 310232
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)

Re: The Quotient ID

2010-06-02 11:11 • by grknight (unregistered)
Why not divide by 1.21 gigawatts for a time machine?

Re: The Quotient ID

2010-06-02 11:13 • by Anonymous (unregistered)
310240 in reply to 310228
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!!!".

Re: The Quotient ID

2010-06-02 11:23 • by Bruce W (unregistered)
310242 in reply to 310220
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.

Re: The Quotient ID

2010-06-02 11:36 • by Max (unregistered)
310243 in reply to 310240
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.

Re: The Quotient ID

2010-06-02 11:38 • by Anon (unregistered)
310244 in reply to 310240
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.

Re: The Quotient ID

2010-06-02 11:47 • by Anonymous (unregistered)
310246 in reply to 310244
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)!

Re: The Quotient ID

2010-06-02 11:51 • by Steve-O (unregistered)
310248 in reply to 310240
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.

Re: The Quotient ID

2010-06-02 11:51 • by Ethan Qix (unregistered)
310249 in reply to 310242
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.

Re: The Quotient ID

2010-06-02 11:53 • by Anonymously Yours (unregistered)
Amateur. My single table database can store anything and has its customer records on a modulus of 17.

Re: The Quotient ID

2010-06-02 12:01 • by Peter (unregistered)
310251 in reply to 310242
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.

Re: The Quotient ID

2010-06-02 12:08 • by warmachine
It is times like this that I wish I had a machinegun.

Re: The Quotient ID

2010-06-02 12:08 • by hatterson
310253 in reply to 310240
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.)

Re: The Quotient ID

2010-06-02 12:13 • by 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.

Re: The Quotient ID

2010-06-02 12:21 • by RobFreundlich
310256 in reply to 310250
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.

Re: The Quotient ID

2010-06-02 12:28 • by Jay (unregistered)
310257 in reply to 310246
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!)

Re: The Quotient ID

2010-06-02 12:32 • by Jay (unregistered)
310258 in reply to 310249
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.

Re: The Quotient ID

2010-06-02 12:44 • by Mason Wheeler
310261 in reply to 310239
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.

Re: The Quotient ID

2010-06-02 13:05 • by 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.

Re: The Quotient ID

2010-06-02 13:23 • by Someone like Kevin (unregistered)
310263 in reply to 310246
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.

Re: The Quotient ID

2010-06-02 13:24 • by frits
310264 in reply to 310254
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!

Re: The Quotient ID

2010-06-02 13:30 • by 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.

Re: The Quotient ID

2010-06-02 13:31 • by 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...

Re: The Quotient ID

2010-06-02 13:31 • by Someone like Kevin (unregistered)
310267 in reply to 310258
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.

Re: The Quotient ID

2010-06-02 13:32 • by 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.

Re: The Quotient ID

2010-06-02 13:37 • by Владмир (unregistered)
310269 in reply to 310214
RogerC:
I feel like my brain just exploded into 1,000,000 pieces.

Mine exploded into 10,000,000 pieces.

Re: The Quotient ID

2010-06-02 13:44 • by kikito (unregistered)
I want to meet the consultant that programmed this.

Re: The Quotient ID

2010-06-02 13:47 • by Kerbleckistan4Life (unregistered)
maybe I needing later
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment