1

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

fombo
  • 103
  • 1
  • 7

1 Answers1

1

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

Oleksii Tambovtsev
  • 2,666
  • 1
  • 3
  • 21
  • I didn't know that! I don't see the utility of inheritance then, this constrains a lot its usage. – fombo Dec 22 '21 at 19:44
  • There is specific cases where inheritance really can help you, but yes, in my opinion it's better to avoid inheritance in most cases, especially if you don't have deepest knowledges in this area. – Oleksii Tambovtsev Dec 22 '21 at 19:50