Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Multiple object references in Oracle 9i
Roman Zhovtulya wrote:
> Hello all,
> Just wondering whether it is possible to make a multiple reference from one
> object to many objects?
> The thing I'm trying to do is to create a reference from one of the
> "student" objects to several "course" objects (that is to reconstruct the
> model where one student takes many courses).
> I'm trying to do it using "varray" as follows:
>
> CREATE OR REPLACE TYPE Stud_reftype AS VARRAY(70) OF REF Studenttype;
>
> CREATE TABLE COURSE (
> CourseNr INTEGER primary key,
> Title VARCHAR(30),
> Hours INTEGER,
> Stud_ref Stud_reftype REFERENCES Student);
>
> (Studenttype is the type of the table student.)
>
> Any suggestions of how to implement it correctly?
>
> Thanks a lot,
> Roman Zhovtulya
Not knowing what you are doing it strikes me that you have chosen the most difficult possible way to implement a relationship that stands at the core of RDBMS technology.
Why not use an INNER or OUTER join between two tables with the primary key of the parent migrating to part of a concatenated key for the child.
If this isn't an academic exercise ... I'd walk away from what you are doing as fast as your feet will take you.
Daniel Morgan Received on Wed Dec 04 2002 - 15:49:07 CST