什么时候使用数据库是个好主意

发布于 2024-10-21 10:26:14 字数 88 浏览 9 评论 0原文

我正在用 C++ 做一个信息检索项目。与将术语存储在向量等数据结构中相比,使用数据库存储术语有哪些优点?更一般地说,什么时候使用数据库而不是数据结构是一个好主意?

I am doing an information retrieval project in c++. What are the advantages of using a database to store terms, as opposed to storing it in a data structure such as a vector? More generally when is it a good idea to use a database rather than a data structure?

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

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

发布评论

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

评论(4

随风而去 2024-10-28 10:26:14
  1. (Shawn):每当您想要保留数据超出程序实例的长度时。 (跨时间持久性)

  2. (Michael Kjörling):每当您需要程序的多个实例时,无论是在同一台计算机还是在许多计算机(例如网络或互联网)中,都可以访问和操作(共享)相同的数据。 (跨网络空间的持久性)

  3. 每当您有大量数据无法装入内存时。

  4. 每当您有非常复杂的数据结构并且您不想重写代码来操作它们(例如搜索、更新它们)时,当数据库程序员已经编写了此类代码并且可能比您(或我)将要编写的代码快得多时 每当您有非常复杂的数据结构并且

  1. (Shawn): Whenever you want to keep the data beyond the length of the instance of the program. (persistence across time)

  2. (Michael Kjörling): Whenever you want many instances of your program, either in the same computer or in many computers, like in a network or the Net, access and manipulate (share) the same data. (persistence across network space)

  3. Whenever you have very big amount of data that do not fit into memory.

  4. Whenever you have very complex data structures and you prefer to not rewrite code to manipulate them, e.g search, update them, when the db programmers have already written such code and probably much faster than the code you (or I)'ll write.

国产ˉ祖宗 2024-10-28 10:26:14

每当您想要保留数据超出程序实例的长度时?

Whenever you want to keep the data beyond the length of the instance of the program?

一袭白衣梦中忆 2024-10-28 10:26:14

除了Shawn 指出的持久性之外:每当您希望程序的多个实例能够轻松共享数据时?

内存数据结构很棒,但它们并不能替代持久性。

In addition to Shawn pointing out persistence: whenever you want multiple instances of the program to be able to easily share data?

In-memory data structures are great, but they are not a replacement for persistence.

木格 2024-10-28 10:26:14

这实际上取决于范围。例如,如果您要让多个应用程序访问数据,那么数据库会更好,因为您不必担心文件锁等。此外,当您需要执行诸如加入其他操作之类的操作时,您会使用数据库数据、排序等...除非您喜欢实现快速排序。

It really depends on the scope. For example if you're going to have multiple applications accessing the data then a database is better because you won't have to worry about file locks, etc. Also, you'd use a database when you need to do things like joining other data, sorting, etc... unless you like to implement Quicksort.

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