Click here to Skip to main content
13,591,625 members
Rate this:
Please Sign up or sign in to vote.
See more:
In a database, we store a hierarchy of objects with:
- A table OBJECT_NODE containing a list of objects, each object is identified by a numeric value “ID”
- And a table OBJECT_TREE containing the parent ship between these objects

Create Table OBJECT_NODE ( 
	ID 	int, 
	NAME varchar(255) )	Create Table OBJECT_TREE ( 
	PARENT_ID 	int, 
	CHILD_ID 	int )

For example:

1 ________2________3_______6
| |
| |______7
| |
| |______9
1   N1  1   2
2   N2  2   3
3   N3  2   4
4   N4  2   5
5   N5  3   6
6   N6  3   7
7   N7  4   8
8   N8  4   9
9   N9

For the following 2 questions, please write the procedure for an undefined number of levels in the hierarchy.

1/ Create a SQL Procedure giving all down hierarchy objects of a given node
(in the upper example, all down hierarchy objects of node 2 are 3, 4, 5, 6, 7, 8, 9)


2/ Modify the procedure to give only leaves (objects with no children)
(in the upper example, all leaves objects of node 2 are 5, 6, 7, 8, 9)

Please provide answers to above question based on above hierarchy ..............Plz help me out
Posted 14-Feb-13 4:42am
Updated 14-Feb-13 10:43am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
mahesh.b.p.c 14-Feb-13 10:50am
ok ,if u have answer just help me out
OriginalGriff 14-Feb-13 10:51am
Have you tried to do anything yourself?
joshrduncan2012 15-Feb-13 9:23am
My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180618.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100