Title: More on Primary and Foreign Keys
1More on Primary and Foreign Keys
- Please see speaker notes for additional
information!
2Student system
SQLgt SELECT FROM student00 STUD NAME
STADR CITY
ST ZIP PHONE SSNUM MA ----
-------------------- --------------------
-------------------- -- ----- ----------
--------- -- ENROLLED --------- 1111 Stephen
Daniels 345 Midland Ave Yonkers
NY 03456 9145553456 036574678
BU 09-SEP-00 1212 Jennifer Ames 12 Ave F
Fall River MA 02740
5085558343 034759850 CI 02-SEP-00 2222 Carl
Hersey 12 Ave F Fall River
MA 02740 5085558343 045673945
BU 02-SEP-00 2345 Mary Stanton 156 West
St Taunton MA 04567
5085552090 035678090 CI 05-SEP-00 3333 John
Richards 76 Main St Fall River
MA 02456 5085556498 035656432 CI 06-SEP-00
This is the student00 table that holds
information about the individual student. We will
establish the primary key as studentidno.
SQLgt DESC student00 Name
Null? Type -------------------------------
-------- ---- STUDENTIDNO
VARCHAR2(4) NAME
VARCHAR2(20) STADR
VARCHAR2(20) CITY
VARCHAR2(20) STATE
VARCHAR2(2) ZIP
VARCHAR2(5) PHONE
VARCHAR2(10)
SSNUM
VARCHAR2(9) MAJORCODE
VARCHAR2(2) ENROLLED
DATE
3Student system
SQLgt SELECT FROM stucourse00 STUD COURS SEMTA
GR ---- ----- ----- -- 1111 CIS11 F2000 A- 1111
MAR11 F2000 A 1111 CIS44 S2000 A 1212 CIS44 S2000
A 2222 CIS44 S2000 A 2222 MAN11 F2000 A- 3333
CIS44 F2000 B 3333 CIS44 F2000 B 3333 CIS50 F2000
B 3333 CIS56 S2000 A- 2345 CIS50 F2000 I 1111
CIS50 S2000 A
This is the stucourse00 table that contains
information on the courses the student has
taken. The key to this table will be the
studentidno combined with the coursecd combined
with the semtaken.
SQLgt DESC stucourse00 Name
Null? Type ------------------------------
- -------- ---- STUDENTIDNO
VARCHAR2(4) COURSECD
VARCHAR2(5) SEMTAKEN
VARCHAR2(5) GRADE
VARCHAR2(2)
4Student system
This is the table that holds information about
the major itself. The primary key for this table
will be the majorcode.
SQLgt SELECT FROM major00 MA MAJORNAME
CHAIR -- ----------------------------
-- -------------------- BU Business
Administration Adams CI Computer
Information Systems Grocer SQLgt DESC major00
Name Null? Type
------------------------------- -------- ----
MAJORCODE
VARCHAR2(2) MAJORNAME
VARCHAR2(30) CHAIR
VARCHAR2(20)
5Student system
SQLgt SELECT FROM course00 COURS COURSENAME
CREDITS -----
------------------------------ --------- CIS11
Intro to Computer Info Systems 3 CIS44
Internet User/Developer 3 CIS50
Oracle and SQL 3 CIS56
Visual Basic 3 MAN11
Intro to Management 3 MAR11
Marketing Principles 3 6 rows
selected. SQLgt DESC course00 Name
Null? Type ----------------------
--------- -------- ---- COURSECD
VARCHAR2(5) COURSENAME
VARCHAR2(30) CREDITS
NUMBER(1)
This is the table that holds information about
the courses themselves. The primary key for this
table will be the coursecd.
6Student system
SQLgt ALTER TABLE student00 2 ADD CONSTRAINT
studentidno_pk PRIMARY KEY (studentidno) Table
altered. SQLgt DESC student00 Name
Null? Type ----------------------
--------- -------- ---- STUDENTIDNO
NOT NULL VARCHAR2(4) NAME
VARCHAR2(20) STADR
VARCHAR2(20) CITY
VARCHAR2(20) STATE
VARCHAR2(2)
ZIP
VARCHAR2(5) PHONE
VARCHAR2(10) SSNUM
VARCHAR2(9) MAJORCODE
VARCHAR2(2) ENROLLED
DATE SQLgt SELECT FROM
USER_CONSTRAINTS WHERE TABLE_NAME
'STUDENT00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
----------------- SEARCH_CONDITION ---------------
--------------------------------------------------
--------------- R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT
STUDENTIDNO_PK P STUDENT00
ENABLED
The ALTER statement is used to add the PRIMARY
KEY to the student00 table.
7Student system
SQLgt ALTER TABLE stucourse00 2 ADD CONSTRAINT
thekey_pk PRIMARY KEY (studentidno, coursecd,
semtaken) ALTER TABLE stucourse00 ERROR at
line 1 ORA-02437 cannot enable
(SCOTT.THEKEY_PK) - primary key violated SQLgt
select from stucourse00 STUD COURS SEMTA
GR ---- ----- ----- -- 1111 CIS11 F2000 A- 1111
MAR11 F2000 A 1111 CIS44 S2000 A 1212 CIS44 S2000
A 2222 CIS44 S2000 A 2222 MAN11 F2000 A- 3333
CIS44 F2000 B 3333 CIS44 F2000 B 3333 CIS50 F2000
B 3333 CIS56 S2000 A- 2345 CIS50 F2000 I 1111
CIS50 S2000 A 12 rows selected.
I have a problem here, there are two courses with
the same studentidno, same coursecd and same
semtaken. When I try to create the key, I get an
error because the primary key would be violated.
8SQLgt DELETE FROM stucourse00 2 WHERE
studentidno '3333' AND coursecd 'CIS44' 2
rows deleted. SQLgt INSERT INTO stucourse00 2
VALUES('3333','CIS44','F2000','B') 1 row
created. SQLgt SELECT FROM stucourse00 STUD
COURS SEMTA GR ---- ----- ----- -- 1111 CIS11
F2000 A- 1111 MAR11 F2000 A 1111 CIS44 S2000
A 1212 CIS44 S2000 A 2222 CIS44 S2000 A 2222
MAN11 F2000 A- 3333 CIS50 F2000 B 3333 CIS56
S2000 A- 2345 CIS50 F2000 I 1111 CIS50 S2000
A 3333 CIS44 F2000 B 11 rows selected. SQLgt
ALTER TABLE stucourse00 2 ADD CONSTRAINT
thekey_pk PRIMARY KEY (studentidno, coursecd,
semtaken) Table altered.
I deleted the identical records and added one
back in.
SQLgt DESC stucourse00 Name
Null? Type -----------------------------
-- -------- ---- STUDENTIDNO
NOT NULL VARCHAR2(4) COURSECD
NOT NULL VARCHAR2(5) SEMTAKEN
NOT NULL VARCHAR2(5) GRADE
VARCHAR2(2)
The ALTER creates the Primary Key made up of
three fields studentidno, coursecd, semtaken.
9Student system
SQLgt ALTER TABLE major00 2 ADD CONSTRAINT
majorcode_pk PRIMARY KEY (majorcode) Table
altered. SQLgt DESC major00 Name
Null? Type -----------------------
-------- -------- ---- MAJORCODE
NOT NULL VARCHAR2(2) MAJORNAME
VARCHAR2(30) CHAIR
VARCHAR2(20) SQLgt ALTER
TABLE course00 2 ADD CONSTRAINT coursecd_pk
PRIMARY KEY (coursecd) Table altered.
Here I am creating the primary key for the
major00 table which is majorcode.
Here I am creating the primary key for the
course00 table which is coursecd.
SQLgt DESC course00 Name
Null? Type -------------------------------
-------- ---- COURSECD
NOT NULL VARCHAR2(5) COURSENAME
VARCHAR2(30) CREDITS
NUMBER(1)
10SQLgt SELECT FROM USER_CONSTRAINTS WHERE
TABLE_NAME 'STUCOURSE00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
-------------------- SEARCH_CONDITION ------------
--------------------------------------------------
------------------ R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT THEKEY_PK
P STUCOURSE00
ENABLED SQLgt SELECT FROM
USER_CONSTRAINTS WHERE TABLE_NAME
'MAJOR00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
-------------------- SEARCH_CONDITION ------------
--------------------------------------------------
------------------ R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT
MAJORCODE_PK P MAJOR00
ENABLED SQLgt SELECT FROM
USER_CONSTRAINTS WHERE TABLE_NAME
'COURSE00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
-------------------- SEARCH_CONDITION ------------
--------------------------------------------------
------------------ R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT
COURSECD_PK P COURSE00
ENABLED
11Student system
SQLgt DESC student00 Name
Null? Type -------------------------------
-------- ---- STUDENTIDNO
NOT NULL VARCHAR2(4) NAME
VARCHAR2(20) STADR
VARCHAR2(20) CITY
VARCHAR2(20) STATE
VARCHAR2(2) ZIP
VARCHAR2(5)
PHONE
VARCHAR2(10) SSNUM
VARCHAR2(9) MAJORCODE
VARCHAR2(2) ENROLLED
DATE SQLgt DESC major00 Name
Null? Type
------------------------------- -------- ----
MAJORCODE NOT NULL
VARCHAR2(2) MAJORNAME
VARCHAR2(30) CHAIR
VARCHAR2(20) SQLgtALTER TABLE student00
2 ADD CONSTRAINT majorcode_fk FOREIGN
KEY(majorcode) REFERENCES major00 Table altered.
The alter statement optionally names the key that
is being established. The required portions of
the add constraint are to establish that it is a
foreign key, the name of the foreign key on the
table student00 where it is a foreign key and to
establish the table that I want to link to. Note
the link is to the primary key already
established on the major00 table.
I want to establish majorcode on the student00
table as a foreign key linking to majorcode on
the major00 table.
12Student system
SQLgt SELECT FROM USER_CONSTRAINTS WHERE
TABLE_NAME 'STUDENT00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
------------------- SEARCH_CONDITION -------------
--------------------------------------------------
----------------- R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT
STUDENTIDNO_PK P STUDENT00
ENABLED SCOTT
MAJORCODE_FK R
STUDENT00 SCOTT
MAJORCODE_PK NO ACTION ENABLED
13SQLgt DESC experiment_major Name
Null? Type ------------------------
------- -------- ---- MAJORCODE
VARCHAR2(2) MAJORNAME
VARCHAR2(30) CHAIR
VARCHAR2(20)
Student system
I created the experiment_major table to
experiment with. It is set up just like
major00. Because experiment_major does not have a
primary key, I can not establish a foreign key
link to it. I then created an index in
experiment_major to see if I could link to that,
again it was rejected.
SQLgt ALTER TABLE student00 2 ADD CONSTRAINT
major_fk FOREIGN KEY(majorcode) REFERENCES
experiment_major ADD CONSTRAINT major_fk FOREIGN
KEY(majorcode) REFERENCES experiment_major
ERROR at line 2 ORA-02268 referenced table
does not have a primary key SQLgt CREATE INDEX
major_index ON experiment_major(majorcode) Index
created. SQLgt ALTER TABLE student00 2 ADD
CONSTRAINT major_fk FOREIGN KEY(majorcode)
REFERENCES experiment_major ADD CONSTRAINT
major_fk FOREIGN KEY(majorcode) REFERENCES
experiment_major
ERROR at line
2 ORA-02268 referenced table does not have a
primary key
14SQLgt SELECT FROM USER_CONSTRAINTS WHERE
TABLE_NAME 'STUCOURSE00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
----------------- SEARCH_CONDITION ---------------
--------------------------------------------------
--------------- R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT THEKEY_PK
P STUCOURSE00
ENABLED SQLgt ALTER TABLE stucourse00 2
ADD CONSTRAINT coursecd_FK FOREIGN KEY(coursecd)
REFERENCES course00 Table altered. SQLgt
SELECT FROM USER_CONSTRAINTS WHERE TABLE_NAME
'STUCOURSE00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
----------------- SEARCH_CONDITION ---------------
--------------------------------------------------
--------------- R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT THEKEY_PK
P STUCOURSE00
ENABLED SCOTT
COURSECD_FK R
STUCOURSE00 SCOTT
COURSECD_PK NO ACTION ENABLED
15Student system
SQLgt ALTER TABLE stucourse00 2 ADD CONSTRAINT
studentidno_FK FOREIGN KEY(studentidno)
REFERENCES student00 Table altered. SQLgt
SELECT FROM USER_CONSTRAINTS WHERE TABLE_NAME
'STUCOURSE00' OWNER
CONSTRAINT_NAME C
TABLE_NAME ------------------------------
------------------------------ -
------------------- SEARCH_CONDITION -------------
--------------------------------------------------
----------------- R_OWNER
R_CONSTRAINT_NAME DELETE_RU
STATUS ------------------------------
------------------------------ ---------
-------- SCOTT THEKEY_PK
P STUCOURSE00
ENABLED SCOTT
COURSECD_FK R
STUCOURSE00 SCOTT
COURSECD_PK NO ACTION
ENABLED SCOTT
STUDENTIDNO_FK R
STUCOURSE00 SCOTT
STUDENTIDNO_PK NO ACTION ENABLED
16Student system
A very useful way to find out what constraints
are active in the system that is being used is
the SELECT below. Here I can see the keys for
all four tables.
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME FROM
USER_CONSTRAINTS 2 WHERE TABLE_NAME IN
('STUDENT00', 'STUCOURSE00', 'COURSE00',
'MAJOR00') TABLE_NAME
CONSTRAINT_NAME ------------------------------
------------------------------ COURSE00
COURSECD_PK MAJOR00
MAJORCODE_PK STUCOURSE00
THEKEY_PK STUCOURSE00
COURSECD_FK STUCOURSE00
STUDENTIDNO_FK STUDENT00
STUDENTIDNO_PK STUDENT00
MAJORCODE_FK 7 rows selected.
17SQLgt SELECT studentidno, name 2 FROM
student00 STUD NAME ---- -------------------- 11
11 Stephen Daniels 1212 Jennifer Ames 2222 Carl
Hersey 2345 Mary Stanton 3333 John Richards
Student system
The stucourse00 table has a foreign key on the
studentidno which is linked to the primary key on
the student00 table. This means that I cannot
add a record to the stucourse00 table unless the
studentidno of the new record already exists on
the student00.
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME FROM
USER_CONSTRAINTS 2 WHERE TABLE_NAME IN
('STUDENT00', 'STUCOURSE00') TABLE_NAME
CONSTRAINT_NAME ----------------------
-------- ------------------------------ STUCOURSE0
0 THEKEY_PK STUCOURSE00
COURSECD_FK STUCOURSE00
STUDENTIDNO_FK STUDENT00
STUDENTIDNO_PK STUDENT00
MAJORCODE_FK
SQLgt INSERT INTO stucourse00 2 VALUES
('1234','CIS11','S2000','C') INSERT INTO
stucourse00 ERROR at line
1 ORA-02291 integrity constraint
(SCOTT.STUDENTIDNO_FK) violated - parent key not
found
18SQLgt SELECT 2 FROM course00 COURS
COURSENAME CREDITS -----
------------------------------ --------- CIS11
Intro to Computer Info Systems 3 CIS44
Internet User/Developer 3 CIS50
Oracle and SQL 3 CIS56
Visual Basic 3 MAN11
Intro to Management 3 MAR11
Marketing Principles 3
Student system
This time the studentidno was okay, but I
attempted to add a course that did not exist when
I added the child record to stucourse00.
Therefore the parent violation of coursecd_fk.
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME FROM
USER_CONSTRAINTS 2 WHERE TABLE_NAME IN
('STUCOURSE00','COURSE00') TABLE_NAME
CONSTRAINT_NAME ------------------------
------ ------------------------------ COURSE00
COURSECD_PK STUCOURSE00
THEKEY_PK STUCOURSE00
COURSECD_FK STUCOURSE00
STUDENTIDNO_FK
SQLgt INSERT INTO stucourse00 2 VALUES
('3333','CIS40','S2000','C') INSERT INTO
stucourse00 ERROR at line
1 ORA-02291 integrity constraint
(SCOTT.COURSECD_FK) violated - parent key not
found
19SQLgt INSERT INTO course00 2 VALUES('CIS40',
'Lotus Notes', 3) 1 row created. SQLgt SELECT
FROM course00 COURS COURSENAME
CREDITS ----- ------------------------------
--------- CIS11 Intro to Computer Info Systems
3 CIS44 Internet User/Developer
3 CIS50 Oracle and SQL
3 CIS56 Visual Basic
3 MAN11 Intro to Management
3 MAR11 Marketing Principles
3 CIS40 Lotus Notes
3 7 rows selected.
Student system
I have now added a course, CIS40 to the course00
table.
SQLgt INSERT INTO stucourse00 2 VALUES
('3333','CIS40','S2000','C') 1 row
created. SQLgt SELECT FROM stucourse00 STUD
COURS SEMTA GR ---- ----- ----- -- 1111 CIS11
F2000 A- 1111 MAR11 F2000 A 1111 CIS44 S2000
A 1212 CIS44 S2000 A 2222 CIS44 S2000 A 2222
MAN11 F2000 A- 3333 CIS40 S2000 C 3333 CIS50
F2000 B 3333 CIS56 S2000 A- 2345 CIS50 F2000
I 1111 CIS50 S2000 A 3333 CIS44 F2000 B
Now when I attempt to add a record to stucourse00
table it is successful because studentidno 3333
exists on student00 and because of the insert
above, CIS40 now exists on course00.
20Student system
SQLgt SELECT CONSTRAINT_NAME, COLUMN_NAME 2
from USER_CONS_COLUMNS 3 WHERE TABLE_NAME
4 IN ('STUDENT00', 'STUCOURSE00', 'COURSE00',
'MAJOR00') CONSTRAINT_NAME
COLUMN_NAME ------------------------------
------------------------------ COURSECD_FK
COURSECD COURSECD_PK
COURSECD MAJORCODE_FK
MAJORCODE MAJORCODE_PK
MAJORCODE STUDENTIDNO_FK
STUDENTIDNO STUDENTIDNO_PK
STUDENTIDNO THEKEY_PK
STUDENTIDNO THEKEY_PK
COURSECD THEKEY_PK
SEMTAKEN 9 rows selected.
This shows the constraint name and the columns
involved. Note that for THEKEY_PK there are
three columns listed because this key is made up
of three columns.
21Student system
This includes the table name in case there is
possibility for confusion.
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME,
COLUMN_NAME 2 FROM USER_CONS_COLUMNS 3
WHERE TABLE_NAME 4 IN ('STUDENT00',
'STUCOURSE00', 'COURSE00', 'MAJOR00') TABLE_NAME
CONSTRAINT_NAME
COLUMN_NAME ------------------------------
------------------------------ ---------------- ST
UCOURSE00 COURSECD_FK
COURSECD COURSE00
COURSECD_PK COURSECD STUDENT00
MAJORCODE_FK
MAJORCODE MAJOR00
MAJORCODE_PK MAJORCODE STUCOURSE
00 STUDENTIDNO_FK
STUDENTIDNO STUDENT00
STUDENTIDNO_PK STUDENTIDNO STUCOUR
SE00 THEKEY_PK
STUDENTIDNO STUCOURSE00
THEKEY_PK COURSECD STUCOURSE0
0 THEKEY_PK
SEMTAKEN 9 rows selected.
22Student system
The disable clause turns of the coursecd_pk
constraint and the cascade takes care of foreign
keys that link to it.
SQLgt ALTER TABLE course00 2 DISABLE CONSTRAINT
coursecd_pk 3 CASCADE
SQLgt INSERT INTO stucourse00 2 VALUES
('2222','MAR55','S2000','C')
SQLgt SELECT FROM course00 COURS COURSENAME
CREDITS -----
------------------------------ --------- CIS11
Intro to Computer Info Systems 3 CIS44
Internet User/Developer 3 CIS50
Oracle and SQL 3 CIS56
Visual Basic 3 MAN11
Intro to Management 3 MAR11
Marketing Principles 3 CIS40
Lotus Notes 3
I am now enabling the coursecd_pk on course00.
SQLgt ALTER TABLE course00 2 ENABLE CONSTRAINT
coursecd_pk Table altered.
23Student system
When I try to enable the foreign key associated
with coursecd on the stucourse00 table, I am
refused because of the MAR55 record I added.
SQLgt ALTER TABLE stucourse00 2 ENABLE
CONSTRAINT coursecd_fk ALTER TABLE
stucourse00 ERROR at line 1 ORA-02298 cannot
enable (SCOTT.COURSECD_FK) - parent keys not found
SQLgt INSERT INTO course00 2 VALUES('MAR55','MAR
KETING',3) 1 row created. SQLgt ALTER TABLE
stucourse00 2 ENABLE CONSTRAINT
coursecd_fk Table altered.
I inserted the MAR55 course into course00 and
re-executed the enable, it worked because the
parent was now found.
SQLgt SELECT FROM course00 WHERE coursecd
'MAR55' COURS COURSENAME
CREDITS ----- ------------------------------
--------- MAR55 MARKETING
3 SQLgt SELECT FROM stucourse00 WHERE
coursecd 'MAR55' STUD COURS SEMTA GR ----
----- ----- -- 2222 MAR55 S2000 C
The parent is on course00 and the child is on
stucourse00.
24Student system
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME,
COLUMN_NAME 2 FROM USER_CONS_COLUMNS 3
WHERE TABLE_NAME 4 IN ('STUCOURSE00',
'COURSE00') TABLE_NAME
CONSTRAINT_NAME COLUMN_NAME -------
----------------------- --------------------------
---- ---------------- STUCOURSE00
COURSECD_FK
COURSECD COURSE00
COURSECD_PK COURSECD STUCOURSE0
0 STUDENTIDNO_FK
STUDENTIDNO STUCOURSE00
THEKEY_PK STUDENTIDNO STUCOUR
SE00 THEKEY_PK
COURSECD STUCOURSE00
THEKEY_PK SEMTAKEN
SQLgt ALTER TABLE course00 2 DROP PRIMARY KEY
3 CASCADE
The primary key for course00 is dropped and the
cascade also drops all keys that link to it.
SQLgt SELECT TABLE_NAME, CONSTRAINT_NAME,
COLUMN_NAME 2 FROM USER_CONS_COLUMNS 3
WHERE TABLE_NAME 4 IN ('COURSE00',
'STUCOURSE00') TABLE_NAME
CONSTRAINT_NAME COLUMN_NAME -------
----------------------- --------------------------
---- -------------- STUCOURSE00
STUDENTIDNO_FK
STUDENTIDNO STUCOURSE00
THEKEY_PK STUDENTIDNO STUCOUR
SE00 THEKEY_PK
COURSECD STUCOURSE00
THEKEY_PK SEMTAKEN
25Student system
The primary key and foreign key that I dropped
have now been put back.
SQLgt ALTER TABLE course00 2 ADD CONSTRAINT
coursecd_pk PRIMARY KEY(coursecd) Table
altered. SQLgt ALTER TABLE stucourse00 2 ADD
CONSTRAINT coursecd_fk FOREIGN KEY(coursecd)
REFERENCES course00 Table altered. SQLgt SELECT
TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME 2
FROM USER_CONS_COLUMNS 3 WHERE TABLE_NAME IN
('COURSE00', 'STUCOURSE00') TABLE_NAME
CONSTRAINT_NAME
COLUMN_NAME ------------------------------
------------------------------ --------------- STU
COURSE00 COURSECD_FK
COURSECD COURSE00
COURSECD_PK COURSECD STUCOURSE0
0 STUDENTIDNO_FK
STUDENTIDNO STUCOURSE00
THEKEY_PK STUDENTIDNO STUCOUR
SE00 THEKEY_PK
COURSECD STUCOURSE00
THEKEY_PK SEMTAKEN