Sobes.tech
Middle

In a linking table — is a composite primary key of two fields correct?

sobes.tech AI

Answer from AI

Yes, in a join table, a composite primary key is usually used, consisting of two (or more) fields that are foreign keys to the related tables. Such a key guarantees the uniqueness of each pair of relations and prevents duplication.

For example, if there are tables Students and Courses, and a join table StudentCourses stores which students are enrolled in which courses, then the primary key in StudentCourses will be composite of student_id and course_id.

This is a standard practice for implementing many-to-many relationships in relational databases.

In a linking table — is a composite primary key of… - sobes.tech