Answer the question
In order to leave comments, you need to log in
How justified is it to store information about files in a database?
Hello. The question is architectural. Let's say the project has a file repository. How generally justified to start a table to store information about the files (the file itself on the disk)? I think it's generally justified, but I'm not sure. As an example: a photo for a news item in the news list (preview_iamge). If we have a files table that lists all files (for now, we will assume that there are only pictures), then we store the file id in preview_iamge, and if there is no table, then the full path from the project root. When deleting a file, if we just put Null everywhere for preview_iamge for news, and then it is immediately clear that the file has been deleted. For images, we can store the resolution of images and even versions in different resolutions, it will be easier to search for them. How do other projects store information about files? Who thinks about this?
Answer the question
In order to leave comments, you need to log in
So far, I have not seen a single reason to store information about files in the database in the description of the problem.
Any action should be caused by an urgent need, and not by abstract reasoning.
What a problem to find the right resolution version by postfixing the file name with the resolution - a puzzle
Other projects do what is required in their particular case.
If you do not need to store any additional information about the file, then you do not need to shove them into the database.
If a file is embedded in a database - for example, it can belong to several categories at once, then you simply cannot do without a database, and in principle there are no such questions.
there is another option:
when uploading a file, it is compiled into small medium full and saved original
in the database with one id you have 4 files that can be used for example for adaptability, or preview or detail output, and 3 types are minimized to reduce the amount of traffic
Bitrixoid to the brain and bonesand such a question? .. ahem..
store information about files in a databasethese are features of the FS by that and the answer is simple - if you need features that the FS is not able to provide * - this is normal . otherwise - such a solution is redundant, and can be an unnecessary source of
Of course it's justified. Some even strive to shove the files themselves into the database :). And if from a practical point of view, then you can use aliases for files, save other related information, manage file access rights, and so on...
How reasonable is it to store information about files in a database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question