Save full path in the bank or just the name with the extension?

4

On the systems I used to develop before, I used to save the full path of the file 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 just put the name of the file with the extension in the registry (and the other data I get 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 that image.

But when it comes to other cases, such as in "hand-held" systems, which is the best way to store a file name in the database (also considering performance and maintenance)? >     

asked by anonymous 04.02.2015 / 13:03

1 answer

8

In my opinion what would make it easier to maintain would be to store only the name.extension;

  • Let's look at a small case:

    You decide to change the current system abruptly, changing many things, including the destination of the files, in order ... it would be much easier to change the path of the files only in one place,

    Imagine you change registry by registry in the database for the new paths, it would be an unnecessary job; remembering that this is a personal opinion.

  • In performance, I do not think it would change much store the entire path vs. file name only (I can not confirm or make certain of this information).

04.02.2015 / 13:14