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: Primary and Foreign key problem

Re: Primary and Foreign key problem

From: Richard Foote <richard.foote_at_bigpond.com>
Date: Sat, 7 Sep 2002 23:41:58 +1000
Message-ID: <wdne9.26976$g9.76570@newsfeeds.bigpond.com>

Hi There,

As I suspect this is a student assignment, a hint is all I can provide (as I had to waste valuable drinking time working things out myself when I studied many moons ago).

Actually the hint is in the error message. Question, do all the FKs in Student point to PKs in Tutorial (or perhaps to just components of PKs)? Increase the size and reduce the number of FKs and you'll be well on your way.

Incidentally, it's good practice to put the PK as the first column(s) of a table.

Good Luck

Richard
"JoaopRAMOS" <joaopramos_at_aol.com> wrote in message news:20020907022229.12660.00002256_at_mb-mg.aol.com...
> The following script reports the error ORA-02270. It's regarding the table
> Students. I don't know if I created right the FKs.
> Can anybody help me please?
>
> Thank you
>
> create table academic
> (employee_id CHAR(8) not null,
> surname VARCHAR2(20) not null,
> first_name VARCHAR2(15) not null,
> CONSTRAINT academic_employee_id_pk primary key (employee_id));
>
> create table tutorial
> (academic_id CHAR(8) null,
> tu_day VARCHAR2(9) not null,
> tu_time CHAR(5) not null,
> tu_room VARCHAR2(7) not null,
> CONSTRAINT tutorial_tdtimtr_pk primary key (tu_day, tu_time, tu_room),
> CONSTRAINT tutorial_academic_id_fk foreign key (academic_id)
> references academic (employee_id));
>
> create table student
> (student_id CHAR(8) not null,
> en_tu_day VARCHAR2(9) null,
> en_tu_time CHAR(5) null,
> en_tu_room VARCHAR2(7) null,
> attend_tu_day VARCHAR2(9) null,
> attend_tu_time CHAR(5) null,
> attend_tu_room VARCHAR2(7) null,
> CONSTRAINT student_student_id_pk primary key (student_id),
> CONSTRAINT student_en_tu_day_fk1 foreign key (en_tu_day)
> references tutorial (tu_day),
> CONSTRAINT student_en_tu_time_fk1 foreign key (en_tu_time)
> references tutorial (tu_time),
> CONSTRAINT student_en_tu_room_fk1 foreign key (en_tu_room)
> references tutorial (tu_room),
> CONSTRAINT student_attend_tu_day_fk2 foreign key (attend_tu_day)
> references tutorial (tu_day),
> CONSTRAINT student_attend_tu_time_fk2 foreign key (attend_tu_time)
> references tutorial (tu_time),
> CONSTRAINT student_attend_tu_room_fk2 foreign key (attend_tu_room)
> references tutorial (tu_room));
Received on Sat Sep 07 2002 - 08:41:58 CDT

Original text of this message

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