Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 需要存储大量文本,图片,视频等数据,可以选用TiDB作为数据库吗?
Can TiDB be chosen as a database for storing large amounts of text, images, videos, and other data?
Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 需要存储大量文本,图片,视频等数据,可以选用TiDB作为数据库吗?
Can TiDB be chosen as a database for storing large amounts of text, images, videos, and other data?
There’s nothing wrong with that. But don’t directly throw image and video files into the database.
A distributed file system should be the best, with the database storing the file paths. However, there’s no rule that says databases can’t store files. I once worked on a system where files were serialized and stored in the database, but those were small files, like ID photos.
It can be stored, but this is not the database’s strong suit.
Thank you very much! I would like to ask another question: when a file is sent, how does a distributed database know which folder it should be stored in? How does a distributed database know what the file path is?
If you want to store files in the database, the application must first receive the files, and the application should have its own logic.
There are two scenarios:
First scenario:
Persisting to disk: The received file should have a fixed storage path. First, use sftp or other transfer tools to store the file locally, then notify the program. The application reads the file, serializes it, and stores it in the database.
Second scenario:
Not persisting to disk: After the application receives the file transfer request, it directly stores the received file stream into the database.
Of course, it is not recommended to do it this way. There should be shared storage or distributed storage systems like NFS/OSS, and you can just store the file path in the database.
Do we need to first figure out how this file was uploaded, whether it was the front-end program or something else?
Thank you for your reply! After reading everyone’s answers, I decided not to store the data directly in the database. What confuses me now is how to store the file data obtained from a server onto the disk (do I need to write an application myself, specify a fixed storage path, and receive the file?). Then, how does the distributed database get this file path?
It can be understood as taking files from one server and storing them on multiple idle servers, using a distributed database to manage this data.
NFS/OSS shared storage is the simplest way to handle this. If there is no shared storage, then the only other option is sftp. You need to write your own sftp implementation class, have the remote server open port 22, and provide you with a username and password. You can then call the implementation class to read and write data on the remote server.
I think what’s missing here is a program, and this program should be responsible for the “take” action you mentioned. Either you write it yourself, or you look for third-party software.
Both object storage and NAS are quite suitable. The database creates indexes.
You can store the addresses of images and videos in the database instead of storing them directly in the database.
In the database, we generally store the file paths. In our environment, images and videos are stored in object storage. There is a URL field in the table.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.