Oracle Community

The social network for Oracle people

Do you think there is a point in arranging an Obfuscated SQL Contest, modeled after the infamous Obfuscated C Contest? (You can see winning C entries here)

In the past I did not think the SQL language is rich enough for that, but recently I've seen quite amazing examples involving xml, model, hierarchies, raw and other advanced uses. Maybe such contest will highlight the infinite capabilities of the amazing SQL language. Maybe it will just be lots of fun.

I'm thinking of something along the C tradition. No rules, just few suggestions. Several judges rating the entries according to what they like. Of course, according to Arrow's Theorem, we may end up without a clear overall winner, but so what.

Opinions?

Share Twitter

Reply to This

Replies to This Discussion

Chen, I don't know what kind of contest for C it is - they closed it, but let me make a first try. Some time ago I posted on the russian SQL.RU forum a solution using model clause - for finding an arithmetic expression tree using Reverse Polish Notation. Be careful, it is in Russian: Arithmetic expression tree.

Several days ago another guy on the forum asked for a parsing arithmetic expression solution. And when I found and looked at my solution - I was really confused - how could I write such a stuff. Found it "obfuscating" ;))

PS
Chen, I read your post again - and saw a link to the winners codes ))
So I think I misinterpreted the word "obfuscated". Does the contest goal - to build query that would produce some kind of a picture or that would be a drawing by itself?

Reply to This

I believe the goal can be summarized as "Show off cool language features, bugs or advanced usage while being as unreadable as possible" .
Drawings are very popular, but are strictly optional.

The arithmetic expression tree is terrific, but can be done much more obfuscated. For example, why use '+' signs that are perfectly readable when you can use ascii codes?

Reply to This

Hi Chen,

Is there a limit on how many SQLs each person can submit?
I have several Obscure/Obfuscated SQL queries on the "Oraqa" website.
The definition of Obscure/Obfuscated SQL is kind of subjective.
for example if a person using hierarchies or XML queries all the time. Then tricky
hierarchies or XML queries will looks pretty easy to understand for him.

Reply to This

Frank, to be fair to other Oracle Community members, each member is allowed only one entry submission. So, I suggest you pick and submit the biggest, most obscure and most difficult query from your library on OraQA.com. Of course, you can always link to your other entries on OraQA.com. Cheers!

Reply to This

I didn't think of a limit. Does 3 per person make sense?
Obfuscated = Code that is very hard to read and understand, often intentionally.
I've read many of your ORAQA queries. While they definitely solve unusual problems, often in an innovative way, you may want to make them even more difficult / unreadable before adding them as an entry.

Yes, the definition of obfuscated is entirely subjective, and the definition of "best obfuscated entry" or "most obfuscated code" is even more so. Thats why it is a good idea that Eddie invited the entire community to comment on the entries, it should even out the game a bit.
A good suggestion would be to use more than one advanced technique in the code - both because displaying advanced features is one of the goals, and because the same person who uses XML or hierarchies all the time may find model, conversions from raw to char or regexps more obfuscated.

Reply to This

I would love to have categories, like one-liner using dual, xml, most useful, model, etc...

I mean writing a huge xml query is fairly far from a plain sql. Model also is.

As you said using more than one technique may render the query most difficult to read. I wonder if I could use a query generated to write a 40'000 lines query that require days to read it and forever + a few centuries to understand it ! Can I use bind variable like :x in my query ?

What about formatting, can I have some sqlplus formatting (like width of the columns) ?

No, I will keep it short as possible and hope you win your bet with Eddie !

Reply to This

Sorry for not replying sooner, and thanks for the reminder.

I think that one liners would be the next context. Maybe something like JAPH context they have for Perl? http://en.wikipedia.org/wiki/Just_another_Perl_hacker

40,000 lines is definitely the wrong way to go about it. As we all know, size matters less than good technique. Bind variables are perfectly fine. SQLPLUS formatting should also be fine.

Thanks for your enthusiasm and looking forward to see your entry.

Reply to This

I am much enthousiatic about one_liner, I think the shortest possible one-line is 13 characters.
select*from t
so 80 characters would hardly be obfuscated due to the number of mandatory keywords, somehow it is a good sign that SQL is hard to be obfuscated, it tends to make it readable for humans

Reply to This

Great idea! I especially like the goal of the contest:

  • To write the most Obscure/Obfuscated SQL query.
  • To show the importance of SQL programming style, in an ironic way.
  • To stress SQL techniques with unusual code.
  • To illustrate some of the subtleties of the SQL language.
  • To provide a safe forum for poor SQL code.

I'm sure Frank Zhou's entries on OraQA.com will be among the front runners.

Reply to This

I'm glad you like the idea, Eddie. I was kind of hoping you will actually organize the contest. You seem to have a knack for this :-)

I'm betting on Laurent Schneider in top three. Rob Van-Wijk should be a strong contender too.

Reply to This

I like this idea. Especially since there are so many advanced SQL features that too many programmers are not even aware of. Anyway, I'd suggest that entries should be as short as possible, since every moron can write a 5 page long unreadable select statement ;-)

Reply to This

Reply to This

RSS

© 2010   Created by Eddie Awad on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service