Answer the question
In order to leave comments, you need to log in
If you make several models for pictures?
Hello, tell me please, I have a category model Category
and pictures Image
, and the corresponding tables in the database for these models. A category can have only one picture, and I thought to make a relationship between Category
and Image
"One to One", but I will also have a product model Product
, products can have many pictures, respectively, if only one model table is usedImage
both for categories and for products, then somehow it doesn’t work out right. And what is the best thing to do then? I thought I could make a separate image model for categories and a separate model for products, but then what about methods common to images, for example, methods: saving an image, deleting, etc. And if you use the "Many-to-many" relationship, then perhaps the problem in the sampling speed appears in the number of tables as well. then it is necessary to create intermediate tables.
What is the best thing to do in such a situation? Thank you in advance for your response.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question