T
T
Torento203452021-05-06 20:24:42
MySQL
Torento20345, 2021-05-06 20:24:42

How does a database work with an image table?

Good evening, tell me this moment.
We have an article and for each article there are 5-10 photos.
For example, we loaded them for the first time and ordered them in order.

But after a while, out of 10, we decided to leave only 2 and fill in 6 new ones.
How to do it right?
When deleting each on the client, immediately send a query to the database?
And what about sending for addition, taking into account that we decided to leave 2 photos from those that already were, and taking into account the new order.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kudrya, 2021-05-06
@Torento20345

Make a separate table for images and a many-to-many relationship

V
Vladimir Korotenko, 2021-05-07
@firedragon

In the images table, make 3 fields
Name
Unique
ID Post ID.
The identifier is used as the name of the file in the file system. When deleting, delete the record and then the file. When pasting in, put the name and identifier of the post, after receiving the identifier, copy the file to the desired location

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question