Search code examples
sqloracleentities

copies of primary key


I understand that in the attendances table there are copies of primary keys (probably from the decomposed entities). What's the difference between PK and PK, FK as you can see in the row with student_id inside the attendances table?


Solution

  • In the Attendance table the PRIMARY KEY isn't simple - it's being composed from two columns:

    student_id, running_id
    

    As I understand, this means that each student can't be an attendant of the same course run twice. And the student_id in Attendance table is a FOREIGN KEY to the students for a data consistency. Can't say for sure why the running_id isn't the FOREIGN KEY either.