News for hackers. Stuff that matters.
Re:Our SQL interview questions by aidos on Tuesday May 28, 2013 @09:45AM (#5779980)
These questions are very simple, though I guess they cover a few of the core concepts. Basic selects, joins, joining the same table twice, left joins and group by.

I'm most worried by the comment "(tricky - people often do an "inner join" leaving out empty departments)". That's a basic question and if that's considered "tricky" you've got a real problem on your hands.

Maybe if you're hiring for a junior position you could excuse someone not knowing about left joins. If it were for a position that had any sort of focus on db work I would pass on the candidate (caveat, when hiring juniors I look for desire to learn above most everything else).

Obviously I'm getting old. "Back in my day" a basic understanding of SQL was just part of the job. Didn't matter what you worked on - you should be able to work with relational database. I'm concerned that the attitude of "I don't need to know that - my ORM does that for me" has become the default outlook. Over the last few years I've had to convince developers several times that the complex aggregation they're writing in their script would be easiest solved by using SQL. Unfortunately, increasingly it seems that newer developers aren't even aware that these tools are available - or how to use them.

If nothing else, relational algebra is a wonderful and elegant subject that is worth learning.

Darn kids, get off my lawn! :)

Re:Our SQL interview questions by wmil on Tuesday May 28, 2013 @09:55AM (#5780035)
> That's a basic question and if that's considered "tricky" you've got a real problem on your hands.

If they aren't warned then it's reasonable to assume that every department has employees. Otherwise why would it exist?

Re:Our SQL interview questions by aidos on Tuesday May 28, 2013 @10:21AM (#5780193)
Fair point. Experience has taught me to internally question whether or not each relationship should use a left join or not. The fact that it says "List all departments" made me think it should be a left join. In fact, to me that screams "left join".

Really, in a philosophical sort of way, it's the use of the query that determines which join to use. They want ALL departments, you give them ALL departments. Using a left join you protect yourself in the future - with a performance hit. As you say, if there was a guarantee that the data didn't contain empty departments you'd use an inner join.

Most importantly, a reasonable developer should know to ask the question - if not of the examiner, at least to themselves. Just making an assumption is not the right approach.

Re:Our SQL interview questions by dspillett on Tuesday May 28, 2013 @01:27PM (#5781277)
It is a good way to expose real world experience.

Client requirements are usually vague enough (heck, internal requirements are sometimes vague enough) for there to be problems like this discovered later. or a given business it might be valid for there to be departments that are empty at a particular time.

Someone with extensive real world experience will know to never assume any detail not included in the specification no matter how much of a non-brainer that assumption might seem at the time. They will either ask if empty sets need to be considered, or they will preface/suffix their answer with "assuming there are no empty departments or you don't want to report on them if there are" or "assuming there might be empty departments and you want them included in the report" - either way they are showing an ability to parse requirements and identify possible ambiguity that should to be queried.

You've got a multi-level differentiator there:

* The bad candidates will not be able to give a working answer

* The fine candidates will give a working answer though might miss the exact requirement (as it isn't properly stated and they just assume)

* The best candidates will spot the deficiency in the spec

Re:Our SQL interview questions by Nick_C on Tuesday May 28, 2013 @11:22PM (#5784388)
I can think of two business reasons straight off: 1) a department changed its name, or 2) the department used to have employees but is now defunct, such as the Typing Pool department.

My point is, to try to be aware of the assumptions that you are otherwise unconsciously putting in to your program's business logic.

Re:Our SQL interview questions by zhodge on Tuesday May 28, 2013 @11:57AM (#5780747)
I'm an aspiring junior developer, and I found Stanford's (online) "Introduction to Databases" course to be excellent. I particularly enjoyed the relational algebra section where we wrote relational algebra queries by hand.

From the newbie's perspective, sometimes it can feel as though beneficial resources on the basics of subjects like relational algebra, SQL, and relational databases are somewhat sparse.

Unfortunately, I did not have enough time to finish the class completely (it required, as it should, a significant amount of time dedicated each week), but I'll definitely be re-enrolling next semester as long as it is offered online again.

Re:Our SQL interview questions by dirktheman on Tuesday May 28, 2013 @10:17AM (#5780172)
I feel exactly the same way. I'm the first one to admit that an ORM can save you a huge amount of time for basic database stuff. However, as queries get more complex I always write them in raw SQL. It's just faster for me. I'm shocked that someone who applies for a programming job wouldn't get these questions right. They're not exactly rocket science, right?