Reputation: 737
create table student(
studentNumber number,
name varchar2(20),
age number
);
create table course(
courseNum number,
courseName varchar2(30),
);
i am new to databases and i wanted to check the best method to link students to courses. Here I have two tables student and course. i would like to link students to courses. Say we have a student with student number 101. It should be linked to courses 1001,1002 and 1003. what would be the best way to link them? I am using oracle SQL.
Upvotes: 0
Views: 221
Reputation: 1244
You can have a table called Registration which will have
RegistrationID, studentNum, courseNum
Upvotes: 1
Reputation: 2929
You should create another table called enrollments with 3 columns:
create table enrollments(
enrollmentId number,
studentNumber number,
courseNum number
);
Then insert a record there linking students and courses together. You can then query for all students in a course, or all courses for a given student using simple joins.
Upvotes: 1