IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query to get the parent table of a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Sat Apr 25, 2009 9:42 am
Reply with quote

Hi All,
Is any way to get the parent table of one particulare table.What query i need to execute to get this?


Regards,
Bipin Peter
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Apr 25, 2009 9:57 am
Reply with quote

Hello,

Quite often a parent/child relationship is logical rather than a physical link (as was done in non-relational systems).

I don't know of a way to guarantee discovery of all possible parent/child relationships via a query.

Depending on how your database was designed, there may be a logical data model available in some case tool that will show these relatonships.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Sat Apr 25, 2009 10:31 am
Reply with quote

Hi Pete,

Check out this LINK

Change the WHERE clause condition to A.TBNAME='youchildtablename'

Sushanth
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Sat Apr 25, 2009 10:51 am
Reply with quote

Thanks alot sushanth ,It work fine..
Bipin Peter
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Apr 25, 2009 8:26 pm
Reply with quote

Hello,

Quote:
It work fine..
With the exception that it will probably not detect all child tables. . . As i mentioned before, many parent/child relatonships are not so "formally" established in the meta-data.

If the query provides everything you need, great, but do be aware that there may be other p/c relationships that it cannot identify.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Sun Apr 26, 2009 1:20 am
Reply with quote

Hi d.sch,

Quote:
be aware that there may be other p/c relationships that it cannot identify.


Can you tell me scenario where it cannot identify.

Because, if tables are created as stand-alone tables, i.e., with no relationships with other tables.
The next Only way is to logically relate them in the program. By this method we cannot identify P/C from the catalogs.

Sushanth
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Apr 26, 2009 2:21 am
Reply with quote

Hello,

Quote:
The next Only way is to logically relate them in the program. By this method we cannot identify P/C from the catalogs.
Exactly icon_smile.gif . Many, many older systems were designed for non-relational technology and when they were converted/migrated to a relatoinal dbms (db2, for example), they were not redefined. The code already "knew" how to enforce relationship rules and continued to do so in the "new" database environment.

This is why i mentioned looking for an external "picture" of the database.

Unless one is working with a database structure that they completely designed/implemented, one should not depend on the structure containing all of the necessary information. Many (actually most, in my experienc) older databases were not completely re-vamped when they were converted to newer database software.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts RC query -Time column CA Products 3
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top