Create new database relationship failed, missing index?

I’m new to LibreOffice. Tried to create a relationship between tables Box and Location which failed with the following error message.

firebird_sdbc error:
*unsuccessful metadata update
*ALTER TABLE Box failed
*could not find UNIQUE or PRIMARY KEY constraint in table Location with specified columns
caused by
‘ALTER TABLE “Box” ADD FOREIGN KEY (“Box Location”) REFERENCES “Location” (“Location Code”)’
at /Users/cloph/build/workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/sdbc/SQLException.hdl:27

I created an index in the Location table on field Location Code requiring Location Code to be unique, but still can’t create the relationship. Is there something else I need to do?

Either you remove the index from “Location Code” and make “Location Code” the foreign key.
Or you link “Box Location” with the current primary key which requires that “Box Location” consists of values from the primary key of the “Location” table.

Thanks Villeroy for your quick response. I ended up adding a UNIQUE constraint to my Location Code field using Tools/SQL.