可以有不同类型多媒体的数据字段

发布于 2024-12-13 00:57:34 字数 191 浏览 1 评论 0原文

我正在创建一个数据库表,其中一列可以采用所有可能的多媒体(文本、视频、音频、图像)的形状。在不过度创建几个不同的列或多个表的情况下,我决定应该有一个文件指针来指向数据驻留在服务器上的位置,并有一个额外的列来指示给定行中存在的数据类型。

我想知道这是否是一个好的设计策略或者是否有更好的现有替代方案?

非常感谢,

帕里贾特

I am creating a database table, one of the columns can take the shape of all possible multimedia (text,video,audio,image). Without going into overkill of creating several different columns or multiple tables I decided that I should rather have a file pointer that points to where the data resides on the server and have an extra column that indicates the type of data present for the given row.

I want to know if this is a good design strategy or if there are better existing alternatives?

Thanks much,

Parijat

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是偏爱你 2024-12-20 00:57:34

这是一个很好的策略。除了文件类型之外,我建议添加一个列来存储文件的长度(以字节为单位),以便在需要在 Content-length 中提供文件时,避免从文件系统中检索它。例如,标题。

如果您希望所有文件的大小相对一致(不像视频文件那样太大),则最好将数据作为二进制 blob 存储在数据库中,但考虑到您希望有不同的媒体类型,并且文件大小可能非常不同,我认为将文件保留在文件系统中并从数据库指向它们更有意义。

This is a fine strategy. In addition to the type of file, I would recommend adding a column that stores the length in bytes of the file, to save you retrieving it from the filesystem when you need to supply it in a Content-length header, for example.

If you expected all files to be of a relatively consistent size (none too large like video files), it might be preferable to store the data as binary blobs in the database, but given that you expect diverse media types and possibly very diverse file sizes, I think it makes more sense to keep the files in the filesystem and point to them from the database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文