Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Another newbie question

Re: Another newbie question

From: Tim Marshall <tmarshal_at_morgan.ucs.mun.ca>
Date: Thu, 14 Feb 2002 17:26:05 -0330
Message-ID: <3C6C2465.FC386A13@morgan.ucs.mun.ca>


Chi wrote:
>
> If a company is setup in fthe following manner:
>
> COMPANY has many DIVISIONS which has many BRANCHES which has many
> UNITS
>
> and I have 4 tables to represent this:
>
> COMPANY
> -------
> COMPANY_ID (PK)
<SNIP>

> UNIT
> ----
> MINISTRY_ID (FK)
> DIVISION_ID (FK)
> BRANCH_ID (FK)
> UNIT_ID (PK)
> UNIT_NAME
I'm not an experienced Oracle person but I develop in a database (which I am afraid to name 8) ) so I think I can answer this one for you:

Presumeably you meant to write COMPANY_ID (FK) above where you wrote MINISTRY_ID (FK)? Even if you didn't, the following still has merit...

One thing to be considered is what happens to the Unit record when there's a reorganization in which, for example, a division moves from one company to another or a branch moves within the company to another division? You can do it, but you've got to have some mechanism whereby your cascaded FKs are changed...that leaves room for breaking things!

IMO, it's much more sensible to have an FK only for the level immediately above. The relations take care of any change mentioned above without having to write a routine to find all the unit records and edit appropriate company and branch and division FKs...

Hope this helps.

-- 
Tim - http://www.ucs.mun.ca/~tmarshal/
 ^o<  
 /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^  "DittoooOOO?" - Ditto
Received on Thu Feb 14 2002 - 14:56:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US