2
I’m with a study project that has to create a kind of gallery. Assuming I have a limit of 20 images per post. How to register these images in the database?
I thought of two hypotheses. In the first I would create about 22 columns in a table called postagens
, would be something like ID TITULO IMG1 IMG2 IMG3 IMG4
and so on. I just don’t think it’s the best way, because it’s so many columns, and not all of them will always be filled. On the one hand I was going to be able to work with each image individually.
In the second hypothesis I thought of only 3 columns, something like ID TITULO CONTEÚDO
. That one Conteúdo
would be the HTML code of the entire post, only in this hypothesis I am limited, because I can not work with each image individually.
I am in doubt between these two hypotheses. Is there a 3rd 4th or 5th? Remembering that the project works directly with images, so the malleability in relation to the administration of the photos is a crucial point
What’s the problem with multiple columns and empty fields? Having to keep unlocking HTML to pull information doesn’t make much sense...
– brasofilo
On second thought, I think you already know what’s best between option 1 and 2. And what you’re looking for is option 3, 4 or 5, but then I think you’d better present a basic DB design and what problems you have with it. . . . Did you ever check the site files? http://answall.com/search?q=%5Bmysql%5D+images+is%3Aquestion
– brasofilo
Vlw @brasofilo. I really preferred the 1st option, only I found this hypothesis a little unfeasible, because I thought it could be too many useless spaces.
– ivan veloso
@Brasofilo, I found a third alternative. Whenever you upload the images, the code will create a unique folder name, and in the BD it will type the ID || Title || Folder name || Cover Image. Then when I click on the post, php will take the name of the folder referring to that post and will list everything. I function EXACTLY as I wanted. And very simple.
– ivan veloso
@Brasofilo what you say is also a good, and it’s something simple too right. I hadn’t thought about it. And look who I’ve done it in, it was only in a comment system.
– ivan veloso