Click here to Skip to main content
15,909,440 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: How to explain recursive CTE in as simple a manner as possible Pin
Richard MacCutchan25-Oct-16 0:29
mveRichard MacCutchan25-Oct-16 0:29 
AnswerRe: How to explain recursive CTE in as simple a manner as possible Pin
Michael Martin25-Oct-16 0:45
professionalMichael Martin25-Oct-16 0:45 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rahul_Biswas25-Oct-16 0:51
professionalRahul_Biswas25-Oct-16 0:51 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Mark_Wallace25-Oct-16 4:34
Mark_Wallace25-Oct-16 4:34 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rajesh R Subramanian25-Oct-16 16:24
professionalRajesh R Subramanian25-Oct-16 16:24 
AnswerRe: How to explain recursive CTE in as simple a manner as possible Pin
Besinger25-Oct-16 1:07
Besinger25-Oct-16 1:07 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rahul_Biswas25-Oct-16 1:14
professionalRahul_Biswas25-Oct-16 1:14 
AnswerRe: How to explain recursive CTE in as simple a manner as possible Pin
Marc Clifton25-Oct-16 2:46
mvaMarc Clifton25-Oct-16 2:46 
After reading the comments here (and Michael's was spot on, IMO), here's my thoughts:

Nice example, though please fix the clickey. At this point, it seems to point to my last post!

Explain: The ‘UNION ALL’ is a syntactic handcuff. What do you mean by "handcuff?"

You might want to reference other explanations, like SQL Anywhere: Example: RECURSIVE UNION[^]

Rahul_Biswas wrote:
Could I have used better formatting for the code snippets?


IMO, yes -- get rid of the extra lines and use them only to separate top level "blocks" like "select" and "union"

Rahul_Biswas wrote:
Or the result-sets?


Yes - get rid of extra lines or use screenshots.

Rahul_Biswas wrote:
How could I have ensured that this article is as helpful as possible to a person who is finding it difficult to grasp the recursive CTE concept?


That's a difficult question. Some suggestions:
  1. a lot of people want to know about performance. Dig into the SQL plan so people get an idea if SQL Server is doing a full table scan, and if it is, are there ways to prevent that?
  2. as silly as it sounds, explain what "recursive" actually means.
  3. What are the alternatives? Can you remove the self-reference (requiring a nullable column) by splitting the table into employees and supervisors? (Why yes, you can.) What are the pros and cons of that architecture and how does it affect the query and performance?
  4. How does this stuff work with an ORM, like EF? Is EF smart enough to use UNION ALL or does it do separate queries or does it bail and leave it up to the coder?
[edit]
You might want to illustrate (with #3 in mind) how you do other queries as well, like:
  1. people that are supervisors but do not have supervisors.
  2. people that are not supervisors but are themselves supervised.
  3. immediate people that are being supervised by supervisors that do not have supervisors.
  4. all people in the hierarchy that are being supervised by supervisors that do or do not have supervisors.
  5. traverse the hierarchy upwards: given a person, who are all their supervisors, recursively.
    [/edit]
Thinking of queries like that delve more into architectural considerations and make for potentially really messy queries.

Hope that helps.

Marc
Imperative to Functional Programming Succinctly

Contributors Wanted for Higher Order Programming Project!

Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rahul_Biswas25-Oct-16 3:25
professionalRahul_Biswas25-Oct-16 3:25 
AnswerRe: How to explain recursive CTE in as simple a manner as possible Pin
kentgorrell25-Oct-16 20:26
professionalkentgorrell25-Oct-16 20:26 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rahul_Biswas25-Oct-16 20:48
professionalRahul_Biswas25-Oct-16 20:48 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
kentgorrell25-Oct-16 21:22
professionalkentgorrell25-Oct-16 21:22 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
Rahul_Biswas25-Oct-16 23:37
professionalRahul_Biswas25-Oct-16 23:37 
GeneralRe: How to explain recursive CTE in as simple a manner as possible Pin
kentgorrell26-Oct-16 12:32
professionalkentgorrell26-Oct-16 12:32 
GeneralWSO CCC OTD 2016-10-25 Pin
OriginalGriff24-Oct-16 22:04
mveOriginalGriff24-Oct-16 22:04 
GeneralRe: WSO CCC OTD 2016-10-25 Pin
Kornfeld Eliyahu Peter24-Oct-16 22:12
professionalKornfeld Eliyahu Peter24-Oct-16 22:12 
GeneralRe: WSO CCC OTD 2016-10-25 Pin
Mel Padden24-Oct-16 22:34
Mel Padden24-Oct-16 22:34 
GeneralRe: WSO CCC OTD 2016-10-25 - We have a winner! Pin
OriginalGriff24-Oct-16 22:39
mveOriginalGriff24-Oct-16 22:39 
GeneralRe: WSO CCC OTD 2016-10-25 - We have a winner! Pin
Mel Padden24-Oct-16 22:51
Mel Padden24-Oct-16 22:51 
GeneralRe: WSO CCC OTD 2016-10-25 - We have a winner! Pin
OriginalGriff24-Oct-16 22:59
mveOriginalGriff24-Oct-16 22:59 
GeneralMQOTD Pin
V.24-Oct-16 21:36
professionalV.24-Oct-16 21:36 
GeneralRe: MQOTD Pin
Johnny J.24-Oct-16 21:37
professionalJohnny J.24-Oct-16 21:37 
GeneralRe: MQOTD Pin
Herman<T>.Instance24-Oct-16 21:43
Herman<T>.Instance24-Oct-16 21:43 
GeneralRe: MQOTD Pin
Johnny J.24-Oct-16 21:48
professionalJohnny J.24-Oct-16 21:48 
GeneralRe: MQOTD Pin
Herman<T>.Instance25-Oct-16 0:04
Herman<T>.Instance25-Oct-16 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.