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

Home -> Community -> Usenet -> c.d.o.server -> RE: Enforcement of 1 to many

RE: Enforcement of 1 to many

From: <mpir_at_compuserve.com>
Date: Tue, 27 Apr 1999 23:58:07 GMT
Message-ID: <7g5iue$ps3$1@nnrp1.dejanews.com>


Why not just a unique index on the appropriate key field of the parent table and a foreign key index on the child table.

You must insert the parent first,but what the heck.

In article <56AEBCBEB11CD211BC9800805FA766FD7CB748_at_ammex006.amp.com>,   "Balasankar, Sudhakar " <ampt1156_at_ammex001.amp.com> wrote:
> Hi Cliff,
> Closest, I can think of enforcing this within database is the rule that
> "every DEPARTMENT must HAVE a MANAGER".
> This rule is in the context of typical DEPARTMENT - EMPLOYEE tables
> relation.
> Every EMPLOYEE must belong to one and only DEPARTMENT. An EMPLOYEE could
> be a MANAGER.
> If we make the MANAGER (FK) in the DEPARTMENT table NOT NULLable, The
> database will enforce that at least one employee must be identified for
> defining a department.
>
> The only restriction in this approach that comes to mind is, we should
> be able to identify that one "special KID".
> It is artificial solution. (But, I have problem with the PARTIALITY).
>
> Hope this helps !
>
> Sudhakar Balasankar
> IS Consultant
> mailto:sudhakar_at_tsp-inc.com
> Phone(888)-332-6602
> Fax (888)-332-6603
>
> > -----Original Message-----
> > From: Clifford Buetikofer [SMTP:clifford_buetikofer_at_merck.com]
> > Posted At: Tuesday, April 27, 1999 9:11 AM
> > Posted To: server
> > Conversation: Enforcement of 1 to many
> > Subject: Enforcement of 1 to many
> >
> > Gurus,
> >
> > I need to enforce a 1 ( mandatory ) to many relationship between 2
> > tables. Can the database do this or should we control it at the
> > application level ? We do have a FK on the child table but how do we
> > enforce ALL parents to have at least 1 child ? Procedurally ?
> >
> >
> > TIA,
> > Cliff
> > ( I have 2 kids so I'm covered )
> >
> >
> > The contents of this message express only the sender's opinion.
> > This message does not necessarily reflect the policy or views
> > of
> > my employer, Merck & Co., Inc. All responsibility for the
> > statements
> > made in this Usenet posting resides solely and completely with
> > the
> > sender.
>
>

--
Joseph R.P. Maloney, CCP,CSP,CDP
MPiR, Inc.
502-451-7404
some witty phrase goes here, I think.

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Apr 27 1999 - 18:58:07 CDT

Original text of this message

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