I want to create a generic Employee table with managers and employees present in different rows of the same table....
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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
Related Q&A from Pat Phelan
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.