Q
Manage Learn to apply best practices and optimize your operations.

Using foreign key to associate managers and employees

I want to create a generic Employee table with managers and employees present in different rows of the same table. Can I apply a foreign key constraint to ensure that if a manager leaves and is replaced by another person, all the people reporting to that manager will be pointed to the new manager? Does a constraint of this type work on a self-referential table, and do I need to make updates to it in a particular order?

No, a foreign key constraint won't help with this kind of processing. You probably want to use a trigger and/or application code to handle this kind of processing. The problem lies in how the business rules are stated and applied, so I can't give you a good example without understanding exactly what you need your system to do.

For More Information

  • What do you think about this answer? E-mail the editors at editor@searchDatabase.com with your feedback.
  • The Best Database Design Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your database design -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close