什么是媒体文件存储在数据库中的最佳方式? [英] What is the best way to store media files on a database?

查看:184
本文介绍了什么是媒体文件存储在数据库中的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要存储在数据库中大量的声音文件,但我不知道这是否是一个很好的做法。我想知道这样做的利弊。

I want to store a large number of sound files in a database, but I don't know if it is a good practice. I would like to know the pros and cons of doing it in this way.

我也想过就可能有链接到这些文件,但也许这将携带不是解决更多的问题。在这个方向的任何经验将受到欢迎:)

I also thought on the possibility to have "links" to those files, but maybe this will carry more problems than solutions. Any experience in this direction will be welcome :)

请注意:该数据库将MySQL的

Note: The database will be MySQL.

推荐答案

每个系统我所知道的,存储大量文件的大存储它们的外部的数据库。你存储所有的可查询数据的数据库中的文件(标题,艺术家,长度等),与​​该文件的部分路径沿。当它的时间来检索文件,解压缩文件的路径,prePEND某些文件根(或URL)到它,并返回。

Every system I know of that stores large numbers of big files stores them externally to the database. You store all of the queryable data for the file (title, artist, length, etc) in the database, along with a partial path to the file. When it's time to retrieve the file, you extract the file's path, prepend some file root (or URL) to it, and return that.

所以,你有一个位置一栏,里面有部分路径,如A / B / C / 1000,然后您再映射到:
HTTP://myserver/files/a/b/c/1000.mp3

So, you'd have a "location" column, with a partial path in it, like "a/b/c/1000", which you then map to: "http://myserver/files/a/b/c/1000.mp3"

请确保您有一个简单的方法在不同的服务器/目录指向媒体数据库,如果你需要进行数据恢复。此外,您可能需要一个例行程序,重新同步与文件存档的内容数据库。

Make sure that you have an easy way to point the media database at a different server/directory, in case you need that for data recovery. Also, you might need a routine that re-syncs the database with the contents of the file archive.

另外,如果你将有数以千计的媒体文件时,不要将其全部保存在一个巨大的目录 - 这是某些文件系统性能的瓶颈。相反,将它们分开成多个平衡子树。

Also, if you're going to have thousands of media files, don't store them all in one giant directory - that's a performance bottleneck on some file systems. Instead,break them up into multiple balanced sub-trees.

这篇关于什么是媒体文件存储在数据库中的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆