D
D
daMage2015-11-28 20:12:36
MySQL
daMage, 2015-11-28 20:12:36

Are foreign keys needed for a one to many relationship table?

Hello. Subject. If they are needed, then what about a situation where, for example, there is a table with complaints, a table with images, and a linking table?
Suppose someone submitted a complaint about images 1, 2 and 3. Then another complaint about images 2 and 4 comes in. So if I try to delete image 2, I will get a constraint on complaint 2. How to be in such a situation? I understand that you can delete all records with image_id=2 from the link table, but this is an extra crutch in the ORM, besides, who knows, maybe the deleted records from the link table will be needed to answer the client or some statistics.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-11-28
@daMage

It is not necessary to delete the image, it is necessary to put the "deleted" attribute on it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question