Skip to content

Commit 21d645c

Browse files
committed
Fix problem statement example: PK collision, not secondary
The current implementation already prevents joining on common secondary attributes. The problem semantic matching solves is coincidental name collisions in primary key attributes (e.g., Student.id vs Course.id).
1 parent 3baa07a commit 21d645c

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

docs/SPEC-semantic-matching.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ DataJoint 2.0 introduces **semantic matching** where two attributes are matched
2525

2626
This prevents accidental joins on attributes that happen to share the same name but represent different entities.
2727

28-
#### Example: Name Collision
28+
#### Example: Primary Key Name Collision
2929

3030
Consider two tables:
31-
- `Student(student_id, name)` - where `name` is the student's name
32-
- `Course(course_id, name)` - where `name` is the course title
31+
- `Student(id, name)` - where `id` is the student's primary key
32+
- `Course(id, instructor)` - where `id` is the course's primary key
3333

34-
With current behavior: `Student * Course` would attempt to join on `name`, producing meaningless results or an error.
34+
With current behavior: `Student * Course` joins on `id`, producing meaningless results where student IDs are matched with course IDs.
3535

36-
With semantic matching: The `name` attributes have different lineages (one originates in Student, the other in Course), so they would **not** be matched. Instead, the join would be a Cartesian product, or more likely, an error would be raised about incompatible namesake attributes.
36+
With semantic matching: `Student.id` and `Course.id` have different lineages (one originates in Student, the other in Course). They are **non-homologous namesakes**, so an error is raised rather than performing an incorrect join.
37+
38+
Note: The current implementation already prevents joining on common *secondary* attributes (e.g., if both had a `name` attribute). The problem semantic matching solves is coincidental name collisions in *primary key* attributes.
3739

3840
## Key Concepts
3941

0 commit comments

Comments
 (0)