One to many using a primary-key and foreign-key relationship
SQL>
SQL>
SQL> CREATE TABLE Programmer
2 (lect_id VARCHAR2(10) NOT NULL,
3 lect_name VARCHAR2(20),
4 PRIMARY KEY (lect_id));
Table created.
SQL>
SQL> CREATE TABLE Course
2 (course_id VARCHAR2(10) NOT NULL,
3 course_name VARCHAR2(20),
4 lect_id VARCHAR(10),
5 PRIMARY KEY (course_id),
6 FOREIGN KEY (lect_id) REFERENCES Programmer (lect_id)
7 ON DELETE CASCADE);
Table created.
SQL>
SQL> drop table Programmer cascade constraints;
Table dropped.
SQL> drop table Course cascade constraints;
Table dropped.
Related examples in the same category