Home > OS >  key is not present in referenced table but it seems yes it is
key is not present in referenced table but it seems yes it is

Time:12-23

I have the parent table "persona"(people), which child tables "clients" and "treballadors"(workers) inherit from. I inserted one row in each child table. I also have a table, "passis"(cards), which is related with "persona" 1-1. Not all persons have a card, but all cards belong to a person, so the cards table receives the foreign key. However, when I try to insert a row into the table, the following foreign key-related error triggers: enter image description here

As you can see, a record in table persona with id=2 is actually present. Why then the error?

This is how table 'passis' looks like: enter image description here

CodePudding user response:

I see on the screenshot that table persona has 2 child tables. I suppose that your problem is about incorrect usage of inheritance and foreign keys. You can read more here and here

  • Related