Comment On The Omni ID

Please take a quick moment to fill out the WTF Reader Survey! Joshua had recently started his job at a consulting firm. To get his feet wet, he was added to the team on an application they maintained for the juvenile court system. Fortunately, it had been developed entirely by the company, and everyone Joshua had met at the company seemed to have a good head on their shoulders. Plus it wasn't too big of an application, making it an ideal environment for Joshua to learn. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: The Omni ID

2007-11-26 15:30 • by wfwaf (unregistered)
Guy's got a point. Wouldn't want to hit any hard-coded table limits in the database.

Re: The Omni ID

2007-11-26 15:37 • by My Name (unregistered)
Since I don't understand why Joshua wanted to change the DB design that handled everything else correctly by a more senior developer, that must be the WT... wait I get it now

Re: The Omni ID

2007-11-26 15:40 • by Anonymous Coward (unregistered)
162320 in reply to 162315
wfwaf:
Guy's got a point. Wouldn't want to hit any hard-coded table limits in the database.


Given the insanity of this system and all of the juvenile delinquents it'll create, the 18x10^16 of an unsigned bigint is woefully insufficient.

Re: The Omni ID

2007-11-26 15:42 • by snoofle
162321 in reply to 162317
Soooo not the right way to do this, but given Roy's mandate...

Screen format for ContextFieldId: 'TableName|Data'
[1] 'Case|Big-Int-Value-here'
[2] 'Hearing|nvarchar[16]-here'
[3] 'Motion|int-here'
[4] 'Pleading|nvarchar[32]-here'

or, if you have the luxory of a limited number of tables, use C, H, M and P respectively as the prefixes.

Again, sooo the wrong way to do it but sometimes you gotta play by someone else's rules.

And Joshua's only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.

Re: The Omni ID

2007-11-26 15:58 • by soulfly 69 (unregistered)
only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.


Truest thing I've heard in a long time.

Re: The Omni ID

2007-11-26 16:03 • by pavel (unregistered)
Re: Snoofle

We actually use something sort of like this in some cases, except we have to columns - itemtype and itemid. Itemtype stores the table name, essentially, or if it's more complex than that, the object type.

Not ideal, but for instance, we wouldn't want an "images" table for every table, either.

It would double the number of tables!!

Re: The Omni ID

2007-11-26 16:04 • by Ralphie (unregistered)
162326 in reply to 162315
Premature optimization is the root of all evil.

Re: The Omni ID

2007-11-26 16:06 • by Franz Kafka (unregistered)
162327 in reply to 162321
snoofle:
Soooo not the right way to do this, but given Roy's mandate...

Screen format for ContextFieldId: 'TableName|Data'
[1] 'Case|Big-Int-Value-here'
[2] 'Hearing|nvarchar[16]-here'
[3] 'Motion|int-here'
[4] 'Pleading|nvarchar[32]-here'

or, if you have the luxory of a limited number of tables, use C, H, M and P respectively as the prefixes.

Again, sooo the wrong way to do it but sometimes you gotta play by someone else's rules.

And Joshua's only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.


minimal fix for this particular problem: add a type discriminator column - now it's a variant table.

Why we can't just add columns everywhere for last_updated_by and add triggers i dunno - we do it here and it mostly works, except when it's oracle that does it.

Re: The Omni ID

2007-11-26 16:10 • by Anonymous (unregistered)
162328 in reply to 162323

only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.


only the case if the original (and more senior) developer will never find out about it later and then be annoyed you didnt check with them first...

Premature optimization

2007-11-26 16:12 • by kgj (unregistered)
162329 in reply to 162326
<i>Premature optimization is the root of all evil.</i>

A common misconception.

What the Bible actually says is:

"The love of Premature optimization is the root of all evil."

- Karl

Re: The Omni ID

2007-11-26 16:17 • by I-D (unregistered)
"I can see why you chose this design".
He's truly a gentleman.


Or a big fat liar.

Re: The Omni ID

2007-11-26 16:22 • by James (unregistered)
162334 in reply to 162328
Anonymous:

only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.


only the case if the original (and more senior) developer will never find out about it later and then be annoyed you didnt check with them first...


I disagree. "Better to ask forgiveness than permission", right?

Re: The Omni ID

2007-11-26 16:22 • by SnapCracklerPoop (unregistered)
162335 in reply to 162330
Nice. Now go and fill out the survey and be sure to mention why you hate the name change.

CAPTCHA: OMGURDUM

Re: The Omni ID

2007-11-26 16:34 • by snoofle
162339 in reply to 162334
James:
Anonymous:

only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.


only the case if the original (and more senior) developer will never find out about it later and then be annoyed you didnt check with them first...


I disagree. "Better to ask forgiveness than permission", right?

To Sr. Dev: "I'm sorry, I tried to sit with you a couple of times, but you were extremely overloaded, and I didn't want to bother you with something that seemed fairly simple. If you'd like, I can walk you through what I did and show you how it (already) works (efficiently and) correctly."

I personally have found that people who are protective of anyone else changing their code can *usually* be handled similarly...

Re: The Omni ID

2007-11-26 16:37 • by jBOSS (unregistered)
Kinda missed the point here. Where is the funny conclusion? If there is not any, this is still a WTF.

CAPTCHA: TACOS, yummy!

Golden rule

2007-11-26 16:51 • by ducktype (unregistered)
In such a case, don't walk away from the company -- run! You're wasting your talent.

Re: The Omni ID

2007-11-26 16:54 • by Robert S. Robbins (unregistered)
I would just add a column to the Screen table to indicate the type of ID.

Re: The Omni ID

2007-11-26 17:06 • by FredSaw
162346 in reply to 162321
snoofle:
And Joshua's only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.
What a great idea! The n00b intern changes the database schema without telling anyone, thereby bringing to its knees every application that accesses that database. When the howls of frustration and rage from the users reach the ears of upper management and the scapegoat hunt begins, our hero will be scampering down the road so fast his Reeboks catch on fire.

Re: The Omni ID

2007-11-26 17:51 • by nobody
162351 in reply to 162346
FredSaw:
snoofle:
And Joshua's only mistake: going back to the original developer with a suggestion on how to enhance his design instead of just doing it.
What a great idea! The n00b intern changes the database schema without telling anyone, thereby bringing to its knees every application that accesses that database. When the howls of frustration and rage from the users reach the ears of upper management and the scapegoat hunt begins, our hero will be scampering down the road so fast his Reeboks catch on fire.


Unfortunately I have to agree with FredSaw on this one, you might be able to do it with code, but databases is a different story - you never know how many hardcoded dependencies might be lying around.

Re: The Omni ID

2007-11-26 18:20 • by Hudson (unregistered)
"What if there are more things they want to record about a case later on? We'll keep adding tables and adding tables and before long there will be double the tables!"

True. I mean, a database isn't exactly efficient for storing this kind of stuff (data). Better go with something more universal, like Word. Any updates you'd need to do can be conveniently and quickly done with a find/replace all. Lightning fast, end users could even do it, and they wouldn't need to know anything about SQL.

The best part is, if they want to start formatting the text as it's stored in the "Database", it's all right there man!

Re: The Omni ID

2007-11-26 18:33 • by pm (unregistered)
well - this looks like a developer saying 'tell me I'm right cos my boss is dumb'

There are merits to both sides - sadly realtional databases are cr*p at doing OO things. What the boss wanted was to have a pointer to a base class of 'case thingy' with derived classes of 'pleading', 'motion' etc. Cant easily be done

He should have got a single key type though
and then added a discriminator colum

The poster complaint is that the sql engine doesnt know about the relationship - yup it doesnt

a real WTF

COBOL statement from one of my favorite devs (20 years ago)

MOVE SPACES TO ZEERO

dont ask how it got there u dont want to know


Re: The Omni ID

2007-11-26 18:38 • by Stefan W. (unregistered)
162359 in reply to 162344
Robert S. Robbins:
I would just add a column to the Screen table to indicate the type of ID.

Since tablenames aren't parametric in normal SQL, this wouldn't be the best solution, IMHO.

I would go with Kafkas triggers.

Re: The Omni ID

2007-11-26 18:45 • by Franz Kafka (unregistered)
162360 in reply to 162359
Stefan W.:
Robert S. Robbins:
I would just add a column to the Screen table to indicate the type of ID.

Since tablenames aren't parametric in normal SQL, this wouldn't be the best solution, IMHO.

I would go with Kafkas triggers.



Thanks, but the discriminator column is really a low impact sort of thing that mostly works. It would require apps to populate another column and a backfill, but the potential fallout of an error would be limited.

Re: The Omni ID

2007-11-26 19:16 • by vt_mruhlin
Well, you have a contextfieldid which gives a different id depending on the context...
Why not add a column called fieldidcontext which tells what the actual context is?

Re: The Omni ID

2007-11-26 19:28 • by Nutmeg Programmer (unregistered)
This reminds me of the old and no-longer-funny joke where the sportscaster is asked for scores and he says "24-14, 17-7,..." without naming the teams. We have pointers, but don't know where they are pointing.

Which leads us to Dr. Phil's question: What were you thinking?

Re: The Omni ID

2007-11-26 19:42 • by Matthew (unregistered)
162364 in reply to 162315
Uh, how about an even simpler solution. Just add a new field to the "Screen" table called "type" or something like that. Type would be "Case", "Hearing", etc. You can add more types as needed. We call it a polymorphic association around here. Use 'em all the time.

Re: The Omni ID

2007-11-26 19:43 • by emurphy
162365 in reply to 162362
vt_mruhlin:
Well, you have a contextfieldid which gives a different id depending on the context...
Why not add a column called fieldidcontext which tells what the actual context is?


Splitter!

Re: The Omni ID

2007-11-26 20:59 • by Banana (unregistered)
FFS! It's "too big an application", not "too big of an application". The latter makes no grammatical sense.

Re: The Omni ID

2007-11-26 22:16 • by Just me (unregistered)
It's a sad fact, but this doesn't surprise me. The vast majority of developers I have had to work with do not understand even simple relational database concepts.

I have had to deal with many systems that have a database comprised of one large table. But that must be the correct way to do thing. Why else would Excel be the #1 tool for creating and storing databases :o

I even had a "senior" developer once lecture me on how evil table joins were as they were major performance hits on the system. Well he was correct... when joining two tables with ~50K rows each, with no formal relations defined between the tables, and using non-indexed fields to join the tables. sigh.

Re: Premature optimization

2007-11-26 23:00 • by swordfishBob
162374 in reply to 162329
kgj:
What the Bible actually says is:
"The love of Premature optimization is the root of all evil."

- Karl
If you're going to correct someone, get it right!

"The love of premature optimization is the root of all kinds of evil."

Re: The Omni ID

2007-11-26 23:45 • by ajk (unregistered)
162375 in reply to 162364
Matthew:
Uh, how about an even simpler solution. Just add a new field to the "Screen" table called "type" or something like that. Type would be "Case", "Hearing", etc. You can add more types as needed. We call it a polymorphic association around here. Use 'em all the time.


the problem with such an approach is that it is easy that errors sneak in so the 'type' no longer matches the content of the other columns. the best way is to enforce data integrity at the database level so that programs have no change of entering garbage.

Re: The Omni ID

2007-11-27 00:02 • by CynicalTyler (unregistered)
162376 in reply to 162321
snoofle:
...use C, H, M and P respectively as the prefixes...

Yeah! CHoMP CHoMP CHoMP!

Oh wait... maybe CHiMP... as in the million or so they have in the back room banging on keyboards. Soon they'll design a database capable of housing all human knowledge.

Re: The Omni ID

2007-11-27 00:26 • by Nozz
162377 in reply to 162376
CynicalTyler:

Yeah! CHoMP CHoMP CHoMP!

Oh wait... maybe CHiMP... as in the million or so they have in the back room banging on keyboards. Soon they'll design a database capable of housing all human knowledge.


Or maybe CHuMP, to represent what you look like after such a silly joke. ;)

Re: The Omni ID

2007-11-27 00:30 • by James (unregistered)
You would be very surprised at how often I see this in applications that run the entire companies. I am having to deal with this right and the Sr. Developer previously, now Corporate Solution Architect will not even return my phone calls or emails. Even his boss ignores me now.

Re: The Omni ID

2007-11-27 01:41 • by Anonymous Coward (unregistered)

Re: The Omni ID

2007-11-27 01:59 • by Unfriendly (unregistered)
162390 in reply to 162370
Just me:
It's a sad fact, but this doesn't surprise me. The vast majority of developers I have had to work with do not understand even simple relational database concepts.

I have had to deal with many systems that have a database comprised of one large table. But that must be the correct way to do thing. Why else would Excel be the #1 tool for creating and storing databases :o

I even had a "senior" developer once lecture me on how evil table joins were as they were major performance hits on the system. Well he was correct... when joining two tables with ~50K rows each, with no formal relations defined between the tables, and using non-indexed fields to join the tables. sigh.


Working on an application where some of the tables hold around 1-1,5 billion records (which seems about right for juvenile delinquents...) having everything in the same table is not a good thing....

with a good datamodel you can support almost any type of application. and indexes... oh how i love indexes...

Re: The Omni ID

2007-11-27 03:04 • by Tom_fan_DK (unregistered)
162583 in reply to 162358
pm:
...sadly realtional databases are cr*p at doing OO things... The poster complaint is that the sql engine doesnt know about the relationship...


Well, if you don't know how to use a database, everything involving data will be cr..p, especially the final product.

If you get the chance to read Oracle manuals regarding "create view of <object_type>..." you'll find it amazing: it gives all the ignorance about the data needed by developers that don't want to bother studying how it works a database ;-)

Re: The Omni ID

2007-11-27 03:38 • by Matt (unregistered)
That's pretty apt! The WTF has four stages:

The Case, The Hearing, The Motion and finally, The Pleading.

Re: The Omni ID

2007-11-27 04:05 • by MET
162754 in reply to 162324
pavel:
Re: Snoofle

We actually use something sort of like this in some cases, except we have to columns - itemtype and itemid. Itemtype stores the table name, essentially, or if it's more complex than that, the object type.

Not ideal, but for instance, we wouldn't want an "images" table for every table, either.

It would double the number of tables!!

I really, really hope this is missing it's sarcasm tags.

oh how i love indexes...

Am I the only person who gets annoyed by people not knowing the plural of index is indices?

Re: The Omni ID

2007-11-27 04:12 • by sweavo (unregistered)
162755 in reply to 162330
I-D:
"I can see why you chose this design".
He's truly a gentleman.


But not a diplomat. "I can see"?! Does he already, a mere junior, rate himself as capable of comprehending even the SCOPE of the original design challenge?

When dealing with insecuretins , best to get them teaching you. Then if you are skillful, you will be able to get THEM to have your idea.

Re: The Omni ID

2007-11-27 04:27 • by Peter Stephenson (unregistered)
162756 in reply to 162754

oh how i love indexes...

Am I the only person who gets annoyed by people not knowing the plural of index is indices?


You are not alone ;)
shame they out number us though :(

Re: The Omni ID

2007-11-27 04:30 • by jethrotull (unregistered)
162757 in reply to 162754
No, both forms are correct, 'indices' is merely more elegant, coming directly out of latin. But hey, what do I know, not a native english speaker...

Re: The Omni ID

2007-11-27 04:54 • by Brave-but-foolhardy (unregistered)
162760 in reply to 162754
MET:
oh how i love indexes...

Am I the only person who gets annoyed by people not knowing the plural of index is indices?


Actually, according to Fowler, both indices and indexes are valid English, with indices being used mostly in formal and scientific situations, and indexes being used in popular or colloquial situations. But "there is considerable liberty of choice".

Eg, "the volume is rounded off by splendid indexes" and "Integral, fractional and negative indices" (Fowler's examples)

So there ;-P

Re: The Omni ID

2007-11-27 05:32 • by 28% genius (unregistered)
alter table hearing
add enteredby varchar2(30) default user;

Re: The Omni ID

2007-11-27 06:18 • by Treeki (unregistered)
The real WTF is the use of Vista.

Re: The Omni ID

2007-11-27 06:23 • by I-D (unregistered)
162766 in reply to 162755
sweavo:
I-D:
"I can see why you chose this design".
He's truly a gentleman.


But not a diplomat. "I can see"?! Does he already, a mere junior, rate himself as capable of comprehending even the SCOPE of the original design challenge?

When dealing with insecuretins , best to get them teaching you. Then if you are skillful, you will be able to get THEM to have your idea.


Insecuretins are the number one plague on IT business. Just beyond them are: the big fat liars, the gentlemen, and i-ching/tai-chi-chuang/yoga CEOs.
Mere juniors are way down on the list.

Re: The Omni ID

2007-11-27 06:26 • by hognoxious (unregistered)
162767 in reply to 162328
Anonymous:
only the case if the original (and more senior) developer will never find out about it later and then be annoyed you didnt check with them first...
I'd say Roy's so thick he probably wouldn't notice.

Re: The Omni ID

2007-11-27 06:26 • by hognoxious (unregistered)
162768 in reply to 162328
Anonymous:
only the case if the original (and more senior) developer will never find out about it later and then be annoyed you didnt check with them first...
I'd say Roy's so thick he probably wouldn't notice.

Double the Number of Tables

2007-11-27 08:07 • by Matt Langley (unregistered)
"double the number of tables" is almost always a good thing.

It's pretty much impossible to create unnecessary tables and the worst that can happen is you end up with 2 tables with a one for one relationship - not a big deal really – in fact sometimes desirable if the record length is long and there is an obvious division about when different parts of the record will be accessed.

On the other hand, having unrelated information in the same table just because they happen to have the same format, causes all kinds of referential, security, and scaling issues.

Having a value in a field which might mean one thing or another with no way of telling which is just plain wrong in every way. There is no justification or excuse, Roy should be fired and so should the person who raised the original audit requirement but then did not ask to see how the change could be tracked (or signed it off without understanding it).

Re: The Omni ID

2007-11-27 08:12 • by Troy Mclure (unregistered)
I'm all for shoving as much as I can into one table. In fact I shun modern databases and go with Excel only.

Have more than 10 items on an item? Simple - just add a column called item 11. Hit the max(rows)? Add a new tab. Completely scalable!

Normalization is teh suck.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment