Ich habe einen zusammengesetzten Primärschlüssel, den ich in eine andere Tabelle einfügen möchte.Wie fügt man einen zusammengesetzten Primärschlüssel in eine andere Tabelle ein?
create table courses_instructors
(
courseID int foreign key references Course(C_ID) not null,
instructorID int foreign key references Instructor(I_ID) not null,
primary key (courseID, instructorID), --coourseID and instructorID combined is the composite PK
courseTerm varchar(50) not null,
courseNumber int not null,
courseLocation varchar(50),
courseTime varchar(50),
courseMaxOccupancy int,
courseSeatAvailable int
)
create table courses_students
(
studentID int foreign key references student(S_ID) not null,
courseID int, -- foreign key -- I want this value to the be value that represents the composite PK from the courses_instructors
primary key(studentID, courseID), -- these 2 fields combined would make the composite PK, but with the courseID value I will be able to identify who is the instructor for a course and the other details from the course_instructor table
courseOutcome varchar(50)
)
der Kurs von einem Kurs Tisch kommen alle, die nur den Namen Kurs enthält und die Schüler zusammen mit einem descrption. Die Kurstabelle hat einen Primärschlüssel, der jeden Kurs eindeutig identifiziert.