Skip to content

Lab 4: Few Hints

Overview of Foreign Key

StudentIDNameAge
1John20
2Sarah22
3Michael21


Students
CourseIDCourseNameStudentID
101Math1
102Physics2
103Chemistry1
104Biology3


Courses

In this example:

  • In the “Students” table, “StudentID” is the primary key.
  • In the “Courses” table, “CourseID” is the primary key, and “StudentID” is a foreign key referencing the “StudentID” column in the “Students” table.

This relationship indicates that a student can enroll in multiple courses, but each course is associated with only one student.

Hints

  1. CREATE TABLE Employee_Statistics ( Add all the columns here, also create the FK constraint);
  2. Use LEFT JOIN
  3. INSERT INTO Employee_Statistics (names of columns)
    SELECT column names
    FROM Table1
    LEFT JOIN
    Table2 ON ….
Published inUncategorized