May I ask how the mainstream storage information table about the accessories of the system is designed? Is it decentralized storage or centralized storage?

when designing an attachment storage table for a system, do you use decentralized storage of information to each required table? Or do you centrally store the attachment information in a table and then associate it in the table you need to use? Or are there other plans?

for example, the picture information of the user profile is stored in a field of the user table, and the picture information of the product is stored in a field of the product table. I call this storage method decentralized storage.

all the companies I"ve worked with have been stored in this way.

all the attachments uploaded by users are stored in a table, and then when the query data needs image information, the data is obtained by associating with the id field in other tables. I call this storage method centralized storage.

Please talk about the pros and cons of these two ways.

if there is a better way, please do not hesitate to share.


  1. decentralized storage can reduce table joins and speed up queries
  2. if you store it centrally, you can view all uploaded image attachments. Generally, it is often used for project document management (it can also be used as an attachment version). The disadvantage is that you need to connect a table
  3. .

first of all, it is not recommended to store attachment contents in the form of BLOB, which will greatly increase the capacity of the database and make it difficult to manage and maintain. It is recommended to save the file path.

suggest centralized storage:
1, there will be a slight loss in performance. When querying attachments, you need to check the table associated with the documents-attachments once more, but the impact is not much
2, which is conducive to the abstraction of the function. The function of querying and saving attachments can be made into a general function, which is beneficial to the development of the function.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8a03b-f9f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8a03b-f9f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?