- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The evil's wishes are hard to come by.
Admin
name varchar(20) primary key
That was enough for me..
Admin
See... it works.
Admin
My WTF List:
wftery abounds.
Admin
The manager that hires a clueless tosser as a DBA
Admin
admin_user1 varchar(20) not null,
Clearly, nobody there including the DBA's have the slightest clue about database normalization. Which begs the question: what exactly is it that the DBA's there do?
Admin
Don't forget the Not Null constraints on all the admin columns on the application_admins table. I'm sure if an application has fewer than 5 admins they populate the rest with spaces or something equally horrendous.
Admin
So, what do they do if there are more than 5 admins for a given application? Create a new table with 10 possible admin names?
Admin
I know why you're leaving. Your ClueBat has been used so much it's now a ClueToothpick.
Admin
...and not content with that:
listen_port integer not null unique,
I am not saying it's a good idea (you should use a separate primary key, what if a service changes port?), but at least this one is an integer, unique and not null... so if you wanted to be sloppy, at least use this as the primary key.
And for heaven's sake, if you are so crazy to use a varchar as a pk, at least put some foreign key constraints around. It's not a solution to anything, but at least it will stop you from shooting your foot.
Ugh.
Admin
Ha! And what happens when the same user has admin rights to different applications? PKs HAVE TO BE UNIQUE!!!
Admin
Isn't that the name of the application?
Admin
It is pretty obvious that the name column in that table would be the application name, not the user. So using it as a primary key is a minor WTF (the name could change or there could be multiple versions) but TRWTF is people laughing at a simple data model that they don't understand.
Admin
Beautiful example. I worked for a company which developed software for medical health care specialized on InVitroFertilisation. The had a table like this: create table Patient ( PatientId INTEGER NOT NULL, PatientFirstname VARCHAR(20), PatientLastname VARCHAR(20), ... BabyName VARCHAR(20), BabyDateOfBirth DATE, BabySex INT, --- (SIC!!!) Baby2Name VARCHAR(20), BabyDateOfBirth2 DATE, Baby2Sex INT );
Some day we had a patient with 3 children. Our chief developer decided to change the architecture as follows:
create table Patient ( PatientId INTEGER NOT NULL, PatientFirstname VARCHAR(20), PatientLastname VARCHAR(20), ... BabyName VARCHAR(20), ... Baby2Name VARCHAR(20), ... Baby3Name VARCHAR(20) );
A few months later we had a patient with 4 children. Therefore the chief developer decided to change the architecture to something more scalable.
create table Patient ( PatientId INTEGER NOT NULL, OtherPatientID INTEGER NOT NULL, PatientFirstname VARCHAR(20), PatientLastname VARCHAR(20), ... BabyName VARCHAR(20), ... Baby2Name VARCHAR(20), ... Baby3Name VARCHAR(20) );
OtherPatientID referenced to a PatientId. So whenever a patient had more than 3 children we had to create a new dataset and link it to the original patient. This was genius! The chief developer had been fired. But not because of his genius architectures. So, whenever you plan to get a 4th child by in vitro fertilization you should ask for the hospital's database design :)
Admin
I was there when it first rolled out! I had to legally change my name seven times.
Admin
Cluebat. What a lovely work I've learned.
"Many things in life can be joined. You can join two pieces of wood to construct something useful. Like a double-jointed super-leverage extra-power cluebat."
Admin
Hi,
I am still wondering how they arrived to this :
My best answer is that they brutally copy/paste the second part of the previous query.http://img.tapatalk.com/3281f1ff-4eef-8823.jpg
a+, =) -=Finiderire=-
Admin
And perhaps Doug himself deserves a couple of FAIL points, for creating the particular query. Really, dude, it isn't that hard to explain to people how to properly query a database, even if you've worn the ClueBat down beyond ClueToothpick to ClueSplinter.
Admin
I mean, what a lovely word I've learned.
Admin
What has normalization got to do with anything? They wanted to fit a variable number of admins in a field that only held one admin. That is a problem with the database interface, it has nothing to do with the table structure.
(For instance, in Postgres, I'll never set up a table with an array column, but I'll often write a subquery that returns an array. That is completely kosher.)
Any view is dropped into the join plan, so it's optimized with the rest of the query. Unless by "optimized" you mean "materialized."
Admin
Admin
There are a finite number of Normal Forms for database design. That's boring, but help is on the way! There are an infinite, and maybe even uncountable number of Abnormal Forms.
Admin
Maybe Manager == useless tosser == DBA?
Admin
http://en.wikipedia.org/wiki/Beg_the_question
Admin
But to be fair even the select Doug gave to them is ugly:
select applications.name, attribute, listen_port, AD1.admin1, AD2.admin2 from applications left outer join (select name, MIN(admin) as admin1 from application_admins group by name) as AD1 using name left outer join (select name, MAX(admin) as admin2 from application_admins group by name) as AD2 using name };
This would do the same:
select applications.name, attribute, listen_port, AD.admin1, AD.admin2 from applications left outer join (select name, MIN(admin) as admin1, MAX(admin) as admin2
from application_admins group by name) as AD using name
};
Admin
A DBA goes into a bar, walks up to two tables, and says, "May I join you?"
Admin
I know almost nothing about databases, and I can see some (but not all) of the problems here.
CAPTCHA distineo: From the chorus when a boy band sings about destiny.
Admin
admin_users varchar(210)
Insert comma-separated list. Done.
Admin
Worse than failure.
Instead of having a "variable number of blahs" in a single record, you can have a table of blahs which points to the original, blah-less record. You can then "join" the table of blahs to the record.
That is called "normalization", since it puts the relevant tables into a "normal form".
Admin
Did you hear that sound? It's the sound of this whole entire WTF going over your head.
Admin
TRWTF is naming an application "Dave from accounts".
Admin
A DBA goes into a bar, walks up to two tables, and walks out again utterly confused by the situtation.
Admin
Captcha: tego - when you break out the puns, I got tego.
Admin
Right or wrong, this is simply how table joins have always been done.
Admin
As a public service. There are minor variations that can be used, but a quick mysql definition where one record in the applications table has an applicationID=1 and name='MyApplication':
Admin
+1.
Massive lulz at Meep's post also. Unless it was meant seriously, in which case I feel really sorry for him.
Admin
And when I go interview for jobs I'm told, "You're probably more senior than we're looking for." Well, when you hire junior people this is the kind of software you get because they don't understand the fundamentals. They may be able to crank our PHP, C#, Java, or whatever the language du jour is, but ask them about OO principles or database normalization and they look at you like you're speaking gibberish. I weep for the future of our profession.
Admin
Please, please tell me you're joking. Alternatively, please send me your real name so if we ever get your resume I know not to even waste time reviewing it. Thank you.
Admin
Lol, yeah that's why I like to make all my columns XML based so I can fit whatever sequences of data I want into them.
You joker, you ;-)
Admin
And so it was that two different web applications would never listen on port 80, and port numbers greater than 80 grew up and procreated.
Admin
Admin
Getting job done at the right price is more important!
Admin
Are you having some kind of sixth sense? For all you know, they stored IIS as the application running on port 80.
Don't be an idiot in the vast sea of idiots.
Admin
All my applications are named HAL plus a consecutive number. Right now, I am at HAL 8500.
Admin
They can be blank/empty, but not NULL. We generally do that to avoid any wrinkles of having to do "blank or null" checks.
Admin
I read this as "clueless toaster".
Admin
Admin
There are probably several toasters which could design a better table structure than the one in this article!!!
Admin
He forgot to prefix the columns, now you can only have 10 admin's max, he should have used admin001, be be safe.
Admin
And the database engine, ever the responsible designated driver, says, "Not so fast--let me get your keys first."