Hello. There are 2 tables. Product - Category. Connected via foreign key. Now the essence of the problem. As you understand, by category you can determine which products belong to it. But! There is a problem. Need the ability to delete products. But when deleted, it throws an exception that the object is bound to another object. Because of what you can not delete.

Many will come to mind cascade removal. But, as I understand it, during a cascade delete, all dependent records are deleted. And I need only one.

That is, remove the product, but the category remains.

Thanks in advance.

  • what is the connection? 1 product - many categories? - Dmitry
  • One to many. One category, many goods. - General2001
  • So something is wrong. Most likely the product is "tied" not to the category, but to something else. - XelaNimed
  • I forgot to say. It is tied to 3 objects. There are also subcategories. - General2001
  • one
    show the schema of the tables and your models - tym32167

0