Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
|
|
|______4________8
| |
| |______9
|
|
|______5 OBJECT_NODE OBJECT_TREE
ID NAME PARENT_ID CHILD_ID
	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)
 
Create Procedure GET_OBJECT_CHILDREN (I_PARENT_ID int)

 
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 5:42am
Edited 14-Feb-13 11:43am
v3

1 solution

Rate this: bad
good
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!
  Permalink  
Comments
mahesh.b.p.c at 14-Feb-13 10:50am
   
ok ,if u have answer just help me out
OriginalGriff at 14-Feb-13 10:51am
   
Have you tried to do anything yourself?
joshrduncan2012 at 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
0 Sergey Alexandrovich Kryukov 545
1 OriginalGriff 285
2 Shweta N Mishra 244
3 BillWoodruff 230
4 Mathew Soji 225
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,758
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,735


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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