GeekInterview.com
Series: Subject: Topic:
Question: 42 of 43

Why are recursive relationships are bad? How do you resolve them?

Asked by: Interview Candidate | Asked on: Jul 21st, 2005
Showing Answers 1 - 3 of 3 Answers
John

Answered On : Jun 24th, 2005

Recursive relationships are an interesting and more complex concept than the relationships you have seen in the previous chapters, such as a one-to-one, one-to-many, and many-to-many. A recursive relationship occurs when there is a relationship between an entity and itself. For example, a one-to-many recursive relationship occurs when an employee is the manager of other employeess. The employee entity is related to itself, and there is a one-to-many relationship between one employee (the manager) and many other employees (the people who report to the manager). Because of the more complex nature of these relationships, we will need slightly more complex methods of mapping them to a schema and displaying them in a stylesheet.

Yes  1 User has rated as useful.
  
Login to rate this answer.
ritwik roy

Answered On : Jul 21st, 2005

using the concept of self join may be a solution to this problem. e.g if a table called employees contains three fields like emp_id,name and manager_id and we will have to find out the name of the manager for each employee, then we can use the following code 
select a.name,b.name 
from employees a, employees b 
where a.manager_id=b.emp_id 

  
Login to rate this answer.
Jeetendra Nalawade

Answered On : Nov 12th, 2007

We have used a different way of maintaning recursive relationship. We have created a ancestry table which will give the childs for each entry upto n th level. This way you can fire queries directly to get the child upto any specific level.

Yes  1 User has rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.