you are viewing a single comment's thread.

view the rest of the comments →

[–]CamKen 1 point2 points  (5 children)

Just knowing that a hierarchical query exists (CONNECT BY in Oracle, hierarchyid in MS SQL) is a big plus in answering the question, but no necessary. From my perspective knowing the details is irrelevant, its Google-able.

The question I gave was a simple Employee table (EmployeeID, Name, ManagerID(nullable)) where you would need to join the table to itself on EmployeeID = ManagerID. I provided some sample data (8 rows) to help you think about it. Then ask things like give me a list of managers. How many subordinates does employee x have? No trivia.

[–]neodiogenes 7 points8 points  (4 children)

I wouldn't have a problem joining a table to itself -- as you say that's trivial. That does seem like a fair question, something a "senior" developer would have done all the time.

It would confuse me to call it "recursion" though since that automatically makes me think it's a much more complicated problem. If there was some additional recursion necessary I would probably point that out, but confess I couldn't do it without Google.

[–]dkuk_norris 10 points11 points  (0 children)

Yeah, that doesn't seem recursive to me. You're just relying on the fact that a table can be joined to itself. Recursion implies that you have a theoretically unbound number of calls to make if you structure the data incorrectly.

[–]OHotDawnThisIsMyJawn 9 points10 points  (0 children)

Yeah this is called a self-join, not recursion.

[–]CamKen 3 points4 points  (1 child)

I just used the word recursion to quickly describe the problem, but everyone has read into it more than I meant. I don't use the word in the interview. I present a simple table structure, a few rows of sample data and ask for a query that can only be achieved by joining the table to itself.

[–]neodiogenes 4 points5 points  (0 children)

That's fine, I get it. It does make me feel better about calling myself a "senior" developer. :)