4
In the systems I used to develop back in the day, I used to save the entire file path in the database .
Example:
c:\xampp\htdocs\teste\imagens\post_44\stack_overflow.png
// Image table
imagem
- id = 1
- imagem = imagens/post_44/stack_overflow.png
-post_id = 44
Then, when I started using frameworks, I started to put only the name of the file with the extension in the record (and the other data picked according to the query in the database).
image
- id = 1
- image = stack_overflow.png
- post_id = 44
In this case, I do this because I develop with the Framework in PHP, and it makes it easier for me to "mount" the path of this image.
But, when it comes to other cases, as in systems made "at hand", which of these is the best way to store a file name in the database (also taking into account performance and maintenance)?
I am against saving the path, ever wondered if for some reason you need to rename the folder of the files in the application?
– Luis Henrique
They scored to close. It may even be a bit opinionated, but it’s a problem that many beginners can go through.
– Wallace Maxters
I see no reason to close this question. It is perfectly possible to list the positive and negative points of each option. It is not just a matter of opinion.
– André Ribeiro