Skip to content
techsnow

Joins

Table Relationships

Real apps split data into several tables and link them with keys, so nothing is stored twice.

courses.idcourses.title
1Python
2HTML
enrolments.student_idenrolments.course_id
11
21
22

enrolments.student_id is a foreign key pointing to students.id, and course_id points to courses.id.

CREATE TABLE enrolments (
  student_id INTEGER REFERENCES students(id),
  course_id  INTEGER REFERENCES courses(id)
);