- 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
Admin
Saying "the DB simply needs to do a union on the results from each index" is, IMHO, tantamount to saying "you do not need any indexes, since a full table scan will do".
Assume the table is huge, performance is important and the result set from any part of the query is also huge but the sought after combination is small or even uique.
Admin
You're not storing intermediate results in local variables with descriptive names that describe what you're doing! WTF are you, a parser? Are your children called child[0], child[1] and child[n]? I think I'm gonna copy/paste this in the submit box for Alex....
Admin
The REAL wtf is this code.
Admin
This ACOS(-1) stuff brings back memory of how numbers were stored in the ZX Spectrum's BASIC format. For example, if you entered the following code to make the screen border black (color 0):
10 BORDER 0
That would be stored in memory and on file like this (hex dump):
00 0A (2 bytes for the line number)
AF (code for border)
30 (ascii for '0')
0E (special ascii code meaning "number")
WW XX YY ZZ (floating point data for 0)
This is obiously to avoid parsing the number each time the line is run, but sacrifices a few bytes of memory. So a common memory optimization was:
10 BORDER PI-PI
Where PI is a reservered word and thus stored as one byte. If you want the number 1 instead of 0, you could use for example PI/PI.
Perhaps this guy was an old-school programmer? It's obvious that we has no clue about present day software development priorities.
Admin
You really don't see a reason why native code will execute faster than its -interpreted- counterpart?
Admin
9th District (Alsergrund)
Admin
As 6 billion people walk along the surface of the earth, we're bound to be wearing it down! Certainly it gets smaller and smaller each year.
Admin
i.e. "VLOOPER >= 4", "MOD(VLOOPER, 4) >= 2" and "MOD(VLOOPER, 2)" rewritten in a thoroughly unreadable way.
Admin
While expressions such as VLOOPER >= 4 will translate to 0 or 1 in C or C++, I highly doubt you can make such an assumption in PL/SQL. I know for a fact that there's no direct way in T-SQL to convert a boolean expression such as those above to an integer.
Admin
No, code makes my job harder. EVERY single problem I deal with is caused by code. Either complex code that I need to write (ideally in a simple way), or more likely bugs in code that has been written (often by me...).
Every once in a while I have a problem with management, but those are tiny compared to all the hard problems I have caused by code.
Of course without code I wouldn't have a job at all, so I don't dare say too much. Still, essentially all my problems are caused by code these days.
Admin
You don't need to convert them to an integer, you only have to replace the following zero in the DECODE calls with FALSE in the first two cases.
Admin
why write 3.1416 when you can use PI instead
this also future-proofs your code, you know, just in case the value of PI changes some day...
Admin
On a side note... If there's one thing I can't stand about T-SQL, it's the general "standard" that just about everything is upper-cased. It drives me batty to look at it. Imagine my recent horror when our DBA decided to work that into our coding standards. Yuck.
Does anyone know how that standard came to be?
Admin
I just realized that PL/SQL has a BITAND function, so the "mod magic" is even more of a WTF.
Admin
IBM, the people that brought you present-day SQL to begin with (http://www.answers.com/DB2).
If you have been exposed to any IBM culture, you will quickly learn that PGMRS love to use UPPRCASE identifiers that are FOUR or EGHT characters in length, hence why so many DB2 database tables have column names like ACTNMBR, DEPTCODE, etc.
The practice continues to live on despite IBM's shift to Java.
Admin
Actually, go even go back farther than DB2, which the query language embraced the uppercase statement nomenclature... the practice of using CAPS only was mostly due to the fact that prior to the IBM 5110, most IBM machines didn't have lower case on their code maps and most people didn't care.
IBM later added that capability to the System/370 and was later on the System/23 Datamaster (the immediate predecessor to the IBM PC), IBM Displaywriter, and System/36 when the noticed that people had this fun idea of actually typing documents up and storing memos on a computer rather than just using a computer to print out statements and bills.
Admin
I hate that too.
We've decided to move away from that convention, in favor of the camel/Pascal case scheme.
As my former DBA pointed out, an impedement is that the BOL (books on-line documentation that ships with SQL Server) and much of the literature still use the uppercase keyword convention.
I worked at an Informix shop that had a mix of conventions. That in itself is bad, but what really made it a nightmare is that the SQL engine was case sensitive. We had to remember that ACCOUNTS was upper case, but Departments was simply capitilized. And yes, they used plurals for entity names, too.
Admin
Nice. We have case sensitive databases as well. Two tables, same name, different capitilization (i.e. "blah" vs. "Blah") same table structure and roughly the same data. Which one do I use??? Welcome to my hell.
Admin
That's a bad thing? I always kinda thought that's just how it's done. It doesn't seem unreasonable to me to name a table "Accounts" if it contains information about a bunch of different accounts. Of course, I may feel this way because the database I'm currently maintaining has table names consisting of less than 5 upper case letters plus underscores...-anything- seems better to me than that.
Admin
Sounds like a primitive 'load balancing' scheme
Admin
A database purist will tell you that table names should always be singular. Sure, the 'Customer' table is a collection of customers so on the surface it makes sense to refer to it in the plural. The problem is that each row represents a single entity. Thus, when you say 'Customers.LastName' it actually sounds kind of stupid because you're really looking for the last name of a single customer.
It's not such a huge deal. It's one of those things that people "in the know" will scoff at and snicker at you because they feel that it seperates the men from the boys in terms of database design. Frankly, I can go either way on it, but I distinctly remember the guy I learned SQL from insisting that tables never be named in the plural (for the reasons I described) and it kind of stuck.
I think there are bigger naming issues in the world of database design. Like prefacing every table with the name of the system (i.e. "MyStupidSystem_Customer", "MyStupidSystem_Accounts") or prefacing every stored procedure name with "sp_" or, for that matter, prefacing anything with any consistent and worthless naming convention that just forces you to type those extra few characters on front of everything you do.
Admin
The logic for using singular entity names is that you typically refer to an instance (row) of the data. This lends itself to declarative statements like "an Account <is associated with> a Person". If things are appropriately normalized, an instance should never be a collection of things, but a single thing.
Admin
Anything?
The Informix database I mentioned had mostly 2 character entity names: AA, AB, AC...ZY, ZZ.
*puke*
Admin
I -might- be able to live with poorly named tables if the column names made any damn sense. But in the database I mentioned, it's all S_C_S_L.F_A, S_C_S_L.I_1, S_C_S_L.I_2, S_C_S_L.I_3 and so on. Yearrgh!
The only thing I can think of that'd be worse would Table1.Field1, Table1.Field1, Table2.Field3, etc...
The convention of not using plurals for table names makes sense to me now. I'll be keeping that in mind from now on.
Admin
You missed it. Squint your eyes and look at the monitor from about 4 feet away, and you'll see that he's cleverly encoded the sine wave in the whitespace in front of the parenthesis.
Actually, we have a guy here who writes code with a similarly impaired sense of readability, who must think that we all read his code on some mythical four-foot tall monitors. We used to yell at him, now we just run prettyprint on his code before reading it so we can maintain it..
Admin
Actually, naming stored procedures "sp_<XXX>" is a true WTF. Those procedures actually run more slowly because the name lookup starts by looking in the wrong place. Also, there may be future built-in stored procedures with the axect name chosen, causing no end of trouble.
Admin
The bigger WTF is why SQL Server examines the leading 3 chars of a proc name to see if it's a system proc.
Doesn't almost every system probe starting with the local environment (database, folder, class, context, etc.) then move outward?
Admin
Tell that to Joe Celko. (He helped write the SQL-89 and SQL-92 standards.) Quoting an article: "Use plural or collective nouns for table names since they are sets and not scalar values."
I've also seen him rant on the SQL Server newsgroup about this particular issue on several occasions.
Admin
I'll give you a hint.
It's converting vlooper into a binary representation to get all possible combinations of true/false.
Admin
Back in my Web development consulting days I used to develop on a single box. Of course, the Internet provider would only let me have one database. So what I did is assign each project a TLA and start all the tables pertaining to that project with that TLA. It wasn't that much harder to type 3 more letters per table per query, but allowed me to have literally hundreds of tables in the same database without ever losing my mind about what table belongs to what project.
Admin
<FONT face="Courier New" size=2>hey, awesome icon. it's one of my favorite movies.</FONT>
Admin
Joe Celko can do what he wants.
Maybe he works completely in SQL, and his conventions work for him. I have to program in about a dozen different languages throughout the day, and a consistent style works much better for me.
Humans (and software developers in particular it seems) are very good at pattern recognition. Keywords like "select" leap off the page to me without "visual cues" like all caps.
Admin
sorry, that last post didn't really match what I quoted...
On the issue of singular/plural entity names:
I maintain that singular is the way to go from a data modeling perspective. Relationships exist between instances, not entire entities. Attributes also apply to instances; Person.LastName looks fine but Persons.LastName doesn't really make sense. Thinking in terms of instances when modeling leads to clearer designs.
Admin
I agree. That's why class names are singular. Well, except for System.Drawing.Graphics.
Admin
I would argue that System.Drawing.Graphics is really a collective singular, not plural.
We say "System.Drawing.Graphics is slow" not "System.Drawing.Graphics are slow".
Admin
SELECT CASE WHEN Field1 > Field2 THEN 1 ELSE 0 END FROM Table