No unique constraint error when creating table

I'm trying to create a new table which links to one of my other tables however when trying to create the new table I get an error: "Failed to run sql query: there is no unique constraint matching given keys for referenced table". I looked up a bit and it seems that this error is caused when trying to create a foreign key on columns that aren't unique or a PK.

My tables look like this:
Table_1:
routine_id PK
exercise_id PK
created_at

Table_2: (The one I'm trying to create)
routine_id PK -> reference to Table_1.routine_id
exercise_id PK -> reference to Table_2.exercise_id
workout_id FK
...some other columns that aren't FKS
Was this page helpful?