Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: ER question
"Brian Peasland" <dba_at_remove_spam.peasland.com> schrieb im Newsbeitrag news:409AA5AC.CC21B7A_at_remove_spam.peasland.com...
> bcjm wrote:
> >
> > Say you have two tables, emp and dept. emp has dept_id foreign key
> > which references dept table. What if I need to tract who is the
> > department head? Do you add the emp_id to the dept table or do you
> > create a indicator flag field in the emp table? Which way is better
> > and why. Hope my question is clear.
> >
> > Thanks
>
> The entity DEPT has a department head as one of its attributes. So the
> department head should be a column in the DEPT table. Since that
> department head is also an employee, you will most likely want a FK
> relationship between the dept head column in DEPT and the EMP_ID column
> of the EMP table.
>
That may be the easy way to define a department head.
But is it the "ER-most" way?
What about having a "boss" column in the emp-table identifying the emp_id of the manager of each employee?
Then you
- can select a complete company's user list with the hierarchy
displayed (using the "CONNECT BY"-sql construct)
- and you can use this to identify the top-most manager of a
specific departement.
Just my 2 cent
Olaf Received on Fri May 07 2004 - 09:14:04 CDT