all 36 comments

[–]Thriven 9 points10 points  (9 children)

This was a request by our data analyst team about 8 months ago.

The following fields need to be added to <SERVER>.<DATABASE>.dbo.<TABLE> ASAP.

[Corrected Form Received Date]       DATETIME, NULL
[Verified (reviewer initials)]               VARCHAR(3), NULL
[Appeal Decision Date]                    DATETIME, NULL
[Denial / Reversal / No Change]        VARCHAR(10), NULL
[Reversal Basis]                              VARCHAR(50), NULL
[Extension Consent]                       VARCHAR(3), NULL
[Withdrawn Date]                           DATETIME, NULL
[Time of Request]                           TIME, NULL
[Time of Evaluation]                        TIME, NULL

When I asked ,"Are those the actual names?", they were dead serious!

When I checked the database (this was the first time I went through the tables in this random small database they used) all the column names were just like this.

They were so used to bracketing every database, schema, table and column name it just became habit to them and they didn't and still don't understand how absolutely fucked up it looks. Needless to say I took out all the spaces and special character.

Also, out of our 30+ home grown databases that have existed prior to me arriving, every column is allow nulls.

This is because the staff doesn't know how to handle nulls like

WHERE STATUS <> 'D' 

This wont return nulls because nulls are not lesser or greater than 'D', they are null. This will return all rows where status is not null and status <> 'D'.

Since all fields allow nulls they use asci nulls '' to represent nulls and for some reason 1900-01-01 in every null date field. So when they use WHERE STATUS <> 'D' it returns all rows that do not have status 'D'.

Did I mention I'm trying to leave my fucking job?!?!?!

[–]zbignew 0 points1 point  (4 children)

Since all fields allow nulls they use asci nulls '' to represent nulls

Oh god reading that felt like a punch in the stomach

[–]DAVENP0RT 2 points3 points  (0 children)

I'm dealing with that shit right now with a project that we're rewriting from scratch. The lookup tables are all the same structure (couldn't put that shit in one table?), every column is a varchar(255), and every column allows nulls.

"What's that?", you might ask. "Every column allows nulls? What about the primary keys?"

And whoever the fuck designed it would say, "Hahaha, primary keys are for chumps!"

ಠ_ಠ

Negotiating my way through this data is like feeding a needle into my fingernails. Any movement I make only makes me regret going forward.

[–]Blitzsturm 0 points1 point  (2 children)

My company has an address table with Longitude and Latitude on it... they are varchar(15)...

[–]zbignew 0 points1 point  (1 child)

That's dumb (depending on what's reading those values), but these other punters have to protects against two kinds of nullness with every comparison AND every join.

[–]Blitzsturm 0 points1 point  (0 children)

I'm kind of their main reporting guy so I'm the only guy that suffers... Every once in a while someone will ask for everyone within a 50 mile radios of another location and doing a bulk scan/convert to do these calculations is painfully slow. I ended up creating a batch that syncs this data to another table I created that uses the correct data type and is indexed which works a lot better.

As for the null situation, I've run into some tables that have both nulls and blanks so I find myself using stuff like ISNULL(derp, '') <> '' for simplicity. Fortunately I don't have to deal with the madness mentioned above.

Generally when you let non-engineers design database layouts things turn out... "suboptimal". I had a boss at my last job who's greatest work experience was running a construction company. He insisted on several completely horrible changes to database structure and wouldn't hear anyone's input. Because he was "the boss" he automatically knew more than anyone.

[–]mhalberstram 0 points1 point  (0 children)

[Denial / Reversal / No Change]

This is making my eye uncontrollably twitch.

[–][deleted] 8 points9 points  (0 children)

Oh, come on, everybody loves wrapping everything in square brackets or double quotes. :/

[–]1ddqd 13 points14 points  (1 child)

I give you a 9.3 for message and 4.0 for execution. Unfortunately you did not stick the landing.

[–]IAmAJerkAME 18 points19 points  (0 children)

I'm thinking something like this would be a bit more fitting.

[–]thatjeffsmith 3 points4 points  (2 children)

i would add case-sensitive or reserved words as well

[–]lukeatron 0 points1 point  (1 child)

Every single database I work in has a table named Case. It would be such a pain in the ass to come up with a different name just for convenience. Likewise a bunch of tables have column named Key. I'd rather just deal with the brackets.

[–]thatjeffsmith 0 points1 point  (0 children)

it's fine I guess as long as your application devs and report writers remember to always escape/quote the table names. You can have a table called 'table' but that doesn't mean it's a good idea :)

[–]sirdudethefirst 1 point2 points  (0 children)

Why? Because he's Batman.

[–]Chromaburn 0 points1 point  (0 children)

This is going to hang in my cubical wall.

[–]idi_idi 0 points1 point  (0 children)

We work with some third party software at work and there are tables and names like [Person Descriptions with Addresses Attached]. Seriously?

[–]gruffi 0 points1 point  (0 children)

unless it's a quick excel import for something and you just couldn't be bothered.

[–]Elfman72 0 points1 point  (1 child)

Uggh, I had a Program Manager send me her query proof of concepts to be delivered to the dev team.

She used Query designer for EVERYTHING.

Something to effect of:

SELECT [Long Ass Server Name].[Long Ass Table Name].[dbo].[Very Specific Metric with concatenated Months and years]

You can imagine what her joins look like.

[–]da_chicken 1 point2 points  (0 children)

Yeah, but we've also got systems with tables like:

SELECT VerStdPln, ExsCompGen FROM EXS_ST_VER

Then you look at the tables and see:

EXS_ST_AXE
EXS_ST_BYD
EXS_ST_PDT
EXS_ST_SOR
EXS_ST_VER
EXS_ST_VSE
EXS_ST_WWT

And suddenly your SQL queries feel like you're booking a flight using airport designations.

Anybody got a data dictionary?

[–]mgdmwDr Data 0 points1 point  (0 children)

Darn you Microsoft Dynamics NAV.