- 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
Once I had the pleasure of fixing an application where dates were stored as three TEXT fields (not VARCHAR: the actual TEXT type). One for day, one for month, one for year.
Admin
Once I fixed PHP based CMS, where each page had its own table. And of course: All columns were of type TEXT. This was real fun...
Admin
A long time ago I did a database course at university. Pretty sure I remember having a mini-test once where you had to normalize a set of tables that included a date field; and the "correct" answer was to split the field into a day, month, and year field.
I'm sure glad I didn't learn anything from my education.
Admin
600 columns ought to be enough for everyone.
Admin
The real WTF is the first two submitters haven't heard of OLAP
Admin
The first example seems reasonable if the database was a data warehouse used for reporting purposes.
Admin
Of course there is no "No" table. The non-existence of that table signifies the boolean value "False".
Admin
TRWTF is SharePoint's use of a single table in a single database for storing the item contents of all lists and libraries of all webs of all sites of a site collection...
Admin
Yes, I would go so far as to say its a "good design". But only of course if "good design" is actually a metaphor meaning total sh1t.
Admin
Date tables are pretty much unavoidable as soon as you have important properties of dates that are decided "arbitrarily" and can't be determined by any sane function, only by a lookup table.
I.e., is a particular date a business day? To which accounting period (year/month) should transactions booked on that date go? Hint - it doesn't always equal the calendar year/month part of that date. Etc.
Admin
I thought it signified the boolean FILE_NOT_FOUND.
Admin
This kind of "stuff it all in a table and let god sort'em out!" looks like an old db2 table used with a lot of different COBOL data mapping based on 1st column. It's the kind WT... err "legacy pattern" that can lead to text data overlapping a date field because y'know we don't need this field in this case so save space.
For extra fun, add a few (unsynchronized of course) java/hibernate mappings in the mix.
Admin
Most are WTF...but not necessarily all. I had one project (years ago) where the client was "Creative" in their definition of fiscal quarters, months, and even weeks (yes, sometimes the week ended anywhere from Thursday until Monday, Months were often 4 work weeks, but occasionally 5 - and even once 3, The fiscal quarter did not align with 3 sequential months).....There was NO other way than to use an explicit table.
Admin
That second one looks almost identical the date table for my OLAP cube and almost the same as the one visual studio generates for you when creating a time dimension.
I'd hate to see what a datacube would look like if Kris were to create one. I can just imagine staring at a huge drop down list of dates and times and thinking "if only i could just select 2014...."
Number 1 is a bit WTF though. I like created and updated columns, but in a year table?
Admin
When all you have is a database, everything looks like a table.
Admin
A wooden table.
Admin
I think this actually made me slightly ill. Ughhhhh.
Admin
the last example is PURE genus.
Admin
Yeah, that's the WTFest of them all.
Admin
Nothing wrong with a dbo.YES table!
That way a simple join will give you all the records you want without those pesky where clauses that just make your SQL messy.
Should have a table for every possible filter condition you will potentially use. Saves you from those tricky homophone errors... who can ever remember whether it's where or wear or ware?
Admin
Obviously the real WTF is the superfluous apostrophe in "it's", and the fact that none of you "geniuses" noticed it.
Admin
Just sayin'…
Admin
That is defined by a table that doesn't exist.
Admin
Why is there a "1" in "shit"? Are you 12?
Admin
I have to agree, #2 is not that unusual, there are a lot of legit reasons to use Calendar tables. On the other hand, it is odd to have a foreign key referencing it, or not to fully populate it with all possible dates from the get-go. Not quite WTF level, but odd.
Admin
Why is there a "1" in "shit"? Are you 12?
For the same reason there are peanuts in other peoples. SB obviously eats code for breakfast.
Admin
Justus's setup isn't quite as insane as it might seem at first, having encountered a practically identical record set elsewhere from a major retailer.
This is EDI, stored in a RDBMS, in the only way that's even remotely sane, if you want to preserve it as an EDI document. It's horrendous and it sucks, and it's a shitty technology that was invented by business analysts who discovered a "fax machine" and "acid" at about the same time. But it's used by all the big boys.
Admin
Just trying to find the sense here...
Mick's co-worker needed a way to ensure that years entered in the year field are valid (note that the column is text, not a number). After all, it might not be valid to enter 2015...so I suppose this might make sense.
Kris's table looks like one we use internally. We have a period that looks like yyyyppp (2014001). This would be on the table as the ID, then there's a pair of co-dates that would specify '01/01/2014' to '01/31/2014'. Originally, the ID looked like FY99001, which totally explains the period ID...but anyone remember Y2K? What is it that happens when we go from FY99012 to FY00001? Right. That's why the format is now 2014001. Period tables are flexible...if you need them.
Justus is working on a system that originated in VSAM world (or some other similar keyed flat file). Using multiple files was hard, and so one trick was to use record types to identify differing data record formats, each of which would contain data that adds to the main record. Sometimes, you could even add multiple records of the same type, such as the 410 type in this example. Of course, when we converted our payroll master VSAM file (which looked quite a bit like this) to relational database, we actually used proper relational design, but maybe their customer demanded a "straight conversion" or something. With a customer like that, this could make sense.
The anonymous submitter's multi-column table could be highly flexible when each customer demands to store their own "specialty values", values that you don't want to have to normalize into the database. For example, one of our 30-odd customers wanted to store the date on which the employee was made "do not rehire". Now, "do not rehire" is not something you want to store in the database even as a Y/N flag, since it is a lawsuit magnet. They figured it would be "clever" to store their flag as a date labeled something weaselly like "acceptance into independence program". Yeah, right, we're not adding a normalized date column for that to our database, guys, so you can use one of the anonymous columns in the adhoc table. Of course, it would be a bad idea to use a table like this one for normal relational data, but it's fine for adhoc data, maybe that's what it's being used for here.
Jon and Shane and Sam: WTF I give up. No possible reason.
Admin
Bingo. The only real WTF with that one is possibly the formatting, but even that isn't a stretch if it's being sent straight to a data visualization or BI dashboard.
Admin
This reminds me of the time when I got to review an access database for possible integration into one of our other systems.
The database had been programmed by a doctor who instead of using an incremental counter to assign primary key ids, he used a random number generator. I don't recall if it actually did any checks for uniqueness.
Anyway, the RNG had no user defined bounds, so it was possible for negative ids to be assigned. Did I mention that this ID was displayed prominently to the user in the form front-end?
Admin
In my position as technical consultant, I had a design meeting with a client earlier this month in which he had done exactly that (among other stuff almost as laughable). We get used to this shit after a while, and calmly explain how we would prefer they used our product.
Admin
Calendar tables are good things - they extremely simplify date calculations. Each date has many attributes - is it a company holiday, weekday, weekend, its equivalent in Julian, Chinese, etc? What fiscal year is it part of?
If I want to find all sales on non-Holiday thursdays, I can do that with a calendar table easily.
Admin
That would still be a WTF table. That the WTF was caused at a different level does not suddenly make it a good thing.
Admin
Yet another bright shining example of why developers should never be allowed to design anything to do with a database. After all, it's just a dumping ground for objects. Come to think of it, if all we're doing is saving and retrieving objects, why don't we just write to files, save all those nasty RDBMS license fees.....
Admin
...and we know about open sores databases and all, but they're not trustworthy.
...right?
Admin
Larry found a DUAL table which has no counterpart SINGLE table... It has one row with one column named "DUMMY" containing a single "X"...
Admin
Justus's catalog data table has a "Wooden screen silent L" in it. They clearly misspelled "Wooden table" when entering that data.
Admin
Yeah, fiscal calendar tables are common. Looks like the second one is just that.
The rest are atrocious. Even as a non-DBA, I've never designed tables like that, even the first time that I touched a database. I'm assuming that the people that created these tables probably spend most of their time working with something like WordPress.
Admin
Real programmer ALWAYS store dates as numbers. This is before UTC compatible date classes came into existence. Now you have datetime and datetime2 type of columns available in MSSQL. There are so many classes that do TIMEZONEOFFSETS and thing of that nature.
Still the simplest way of storing a date is count from Unix EPOCH and store the number in a number field. Once you do that it is simple matter of translating that number into any format you want and @CodingHorror is your uncle.
Admin
I've even run across organizations where a single transaction date mapped to multiple accounting periods. At that point, nothing for it but to put the accounting period into the transaction record.
Admin
Admin
you are making my point for me.
Admin
Do real developers double-click the Submit button on a web form?
Admin
I think Mick's coworker was my predecessor... déjà varchar(50)
Databases are to software WTFs as Australia is to biodiversity.
Admin
Admin
You mean "good design" isn't? Isn't that like "political correctness" (which isn't!)
Admin
Then you need a database of leap seconds. An exercise left to the student.
Admin
Agreed, Kris' table appears to be an OLAP Date.Calendar dimension, which I consider the most useful dimension table. Which is the reason I wouldn't bother with something like a Year table - it's stupid easy to derive year information from a regular Date dimension, assuming the correct columns/indices are present. You can use these things in all sorts of fun ways. For instance:
... can't use an index, because of the scalar function. Table scan time (will be slow on large tables). However if you do something like this:
... probably can (depends on how smart the optimizer is), because we've used a range on the join. Consider that most times aggregates consider only a small portion of the complete set (say, only one year), and this becomes even more viable.
Not to mention cases like retail/manufacturing calendars where the fiscal periods being aggregated have no relation to the Gregorian calendar in the first place
Admin
TRWTF is of course Java. How do you get the year from a Java Date object?
of course...except that the docs say this method has been deprecated as of JDK v1.1 (not only that, but it returns the year minus 1900)Java's Calendar class seems a little better, actually having a YEAR field (in amongst the absolute mess of fields it has), but it's an abstract class requiring specific implementations to use for each culture.
Yeah, I'll stick with .NET where DateTime has a Year property (or if I'm stuck with Java for some reason, the Joda library)
Admin
What I really like about Mick's database table is the update timestamp. All that data looks like it was entered in using CTRL-C, CTRL-V