Valerie Meunier

Valerie Meunier

  • 968
  • 693
  • 73.6k

Unable to create relationship 'FK_pets_owners

Jun 8 2023 1:54 PM

Hi

I'm using SSMS 18.11.1.

I have two tables with this rules: one owner can have more than one pets. One pets belongs to one owner.

table owners:
-----------
primary key    nameID    int
        name    varchar(15)


table pets:
----------
primary key    petsID    int
        nameID    int
        pets    varchar(15)

When creating in SSMS a foreign key relationship between table 'pets' and 'owners' and using option Cascade with the Delete rule, i get this error: 

'owners' table saved successfully
'pets' table
- Unable to create relationship 'FK_pets_owners'.  
Cascading foreign key 'FK_pets_owners' cannot be created where the referencing column 'pets.nameID' is an identity column.
Could not create constraint or index. See previous errors.

What's wrong here? Is this a bug?
Thanks
V.


Answers (2)