将 BLOB 存储在数据库中是个好主意吗?

发布于 2024-07-21 23:57:57 字数 493 浏览 2 评论 0原文

一段时间以来,我一直致力于将数据从臃肿的 Excel 工作簿插入 SQL 数据库。 我的团队建议保留 .xls 的备份,他们想知道将 Excel 工作簿实际放入数据库中是否是一个好主意,以便我们项目中的所有相关数据都放在一起。

我知道一些数据库支持插入二进制文件,但显然这不是数据库系统的最初预期用途,所以我认为这是一个坏主意。 我的投票是将工作簿的 URL 放入数据库中,并将工作簿保存在我们 Intranet 上的安全位置。

将 BLOB 放入数据库的优点(如果有的话,除了将生产数据和备份保留在同一位置之外)有哪些优点和缺点?

编辑:只是为了进一步澄清一点,虽然我给出了一个特定的场景,但我打算这个问题主要是关于一般的 BLOB。 当然,无论我能从您的回复中收集到什么对我的具体情况有帮助的信息,我都会表示赞赏。 :)

谢谢,
-罗伯特


PS 对于那些不知道的人来说,BLOB 是“Binary Large Object”的缩写

For a while I've been working on inserting the data from a bloated Excel workbook into a SQL database. My team has suggested keeping a backup of the .xls, and they are wondering if it might be a good idea to put the Excel workbook actually inside the database so that all the relevant data from our project was together.

I know some databases support the insertion of binary files, but clearly this was the not the original intended use of DB systems, and so I'm thinking that this is a bad idea. My vote would be to put URLs to the workbooks in the database and keep the workbooks in a secure location on our intranet.

What are the pros (if any, besides keeping both the production data and the backup in the same place) and cons of putting BLOBs in a database?

Edit: Just to clarify a little further, though I give a specific scenario, I intend this question to primarily be about BLOBs in general. But whatever I can glean for your responses that will assist me in my specific situation is, of course, appreciated. :)

Thanks,
-Robert

P.S. For those of you that didn't know, BLOB is a backcronym for "Binary Large Object"

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

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

发布评论

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

评论(3

风渺 2024-07-28 23:57:57

一般来说,如果有其他成本更低的存储选项,我会避免将 blob 放入数据库中。 当然,在数据库中存储 blob 有充分的理由,但我倾向于谨慎行事,使用 FS 进行文件存储,使用数据库进行数据结构。

由于您使用的是 SQL 2008,因此您可能还会对 FileStream 数据类型。 它可以让你的事情变得更容易。

Generally I avoid putting blobs in the database if there are other storage options that cost less. Sure, there are valid reasons for storing blobs in the database, but I tend to err on the side of caution and use the FS for file storage, and databases for data structures.

Since you're using SQL 2008, you might also be interested in the FileStream data type. It could make things a lot easier on you.

情释 2024-07-28 23:57:57

许多 CMS 软件包(例如 Sharepoint)无论如何都将其全部存储为 BLOB。

快速总结。 我没有个人意见,因为我从未在数据库中设计或开发非常大的 BLOB(例如电子表格)。 我存储了图像和其他较小的东西。

在数据库中:

优点:
假设其他数据以及 BLOB:

  • 它们都位于一处。
  • 备份/恢复是连贯的

缺点:

  • 数据库膨胀
  • 性能

超出数据库

优点:

  • 无数据库膨胀
  • 本地存储

缺点:

  • 备份/恢复更复杂
  • 存在链接损坏的风险

Many CMS packages (such as Sharepoint) store it all as BLOBs anyway.

A quick summary. I have no personal opinions because I've never had to design or develop very large BLOBs (such as spreadsheets) in a DB. I've stored images and other smaller stuff.

In database:

Pros:
Assuming other data as well as BLOBs:

  • it's all in one place.
  • backup/restores are coherent

Cons:

  • Database bloat
  • Performance

Out of database

Pros:

  • No database bloat
  • Stored natively

Cons:

  • Backup/restore more complicated
  • Risk of broken links
我们只是彼此的过ke 2024-07-28 23:57:57

在我看来,如果 Excel 电子表格是一个 blob,那么在需要时打开它会变得更加困难。 另一方面,您不希望在不更改数据的情况下更改备份电子表格,因此在您的情况下,这可能是一个优势。 您还可以考虑要存储电子表格的多少修订版本。 我们经常被要求回顾一年或更长时间以前的客户的原始输入数据(当你收到每日文件时真的很有趣)以找到问题的根源(或者至少证明问题的根源在于他们而不是他们)我们!)。 如果您需要查看数据的不同版本,则您的 blob 需要位于相关表中。 对于您的情况来说,这可能也是一个优势,在我看来,您很少需要实际访问这些数据。

It seems to me that opening the Excel spreadsheet if need be becomes more difficult if it is a blob. On the other hand, you don't want the backup spreadsheet being changed without the data changing, so in your case, this could be an advantage. You might also consider how many revisions of the spreadsheet you want to store. We often get asked to look back at the raw input data from a client that goes back a year or more (really fun when you get a daily file) to find the source of an issue (or at least to prove it was them and not us!). If you need to look at different versions of the data, your blob would need to be in a related table. That is porbably an adavantage in your case too, as it seems to me, you would only rarely need to actually access this data.

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