Foreign key column with possible copy of self's key value?
Posted by: Matt Houser
Date: March 25, 2011 12:51PM

I am creating a table as a hierarchy:

Id - Key, auto increment
ParentId -> FK to self table Id
other data, etc.

The root id has ParentId == NULL.

In order to quickly scan data of all children, I want to also have a column of each child pointing to the RootId node.

This works fine, except I want to include the root node in this scan. So is there an easy way to have the default value of RootId column be a copy of the value automatically generated into Id?

I know I could make it nullable, then do an UPDATE after the fact, but I would like to avoid this.

Thanks,
...Matt

Options: ReplyQuote


Subject
Written By
Posted
Foreign key column with possible copy of self's key value?
March 25, 2011 12:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.