Home » Developer & Programmer » Designer » Generalization relationship (Entity Relationship Diagrammer 9)
Generalization relationship [message #321299] Mon, 19 May 2008 16:59 Go to next message
blagoye6174
Messages: 1
Registered: May 2008
Junior Member
How to create generalization relationship between two entities in Oracle?
e.g. entities: employee and manager - manager is an employee, so he inherits all the attributes of an employee but also may have new ones.

Thank you in advance!
Re: Generalization relationship [message #329831 is a reply to message #321299] Thu, 26 June 2008 12:26 Go to previous message
hhelgen
Messages: 12
Registered: April 2007
Location: Duluth MN
Junior Member
I think a good way to do this is to create a one-to-one relationship to the MANAGER table with the same primary key as the EMPLOYEE table and a foreign key to the primary key of the EMPLOYEE table. See <a href="http://www.orafaq.com/forum/m/329824/103884/#msg_329824" target="_blank"></a>
This is a good technique for defining optional data. Make sure to use outer joins when joining EMPLOYEE and MANAGER.

Then create a new field in employee for MANAGERID with a foreign key to the primary key of the MANAGER table. This gives the relationship that every employee has a manager. But, only managers are in the MANAGER table. You could also add an EMPLOYEE_TYPE field that would tell you if the EMPLOYEE was also a MANAGER. This would save the extra query to the MANAGER table, but it would require knowing that when insert / update is done.

Henry

[Updated on: Thu, 26 June 2008 12:27]

Report message to a moderator

Previous Topic: one to one relatioship
Next Topic: Composite key Problem
Goto Forum:
  


Current Time: Thu Apr 18 18:17:52 CDT 2024