在数据库中存储大量图数据结构

发布于 2024-11-06 05:53:08 字数 478 浏览 7 评论 0原文

这个问题 询问如何在关系数据库中存储单个图。在这种情况下,解决方案很明确:一张表用于节点,一张表用于边。

我有一个随着时间的推移而演变的图形数据结构,所以我想将该图形的“快照”存储在数据库中。我想象有数百张这样的快照。

一种解决方案是为每个快照创建一对全新的节点和边表对(如上所述)。有更好的解决方案吗?

编辑:有人问我想用这个数据库做什么。我相信我不会做任何查询,除非将所有图表从C++转储到MySQL,然后将其全部加载回C++数据结构。因此,我希望使用 MySQL 进行存储,而不是进行高效的随机访问/搜索。

This question asks about storing a single graph in a relational database. The solution is clear in that case: one table for nodes, one table for edges.

I have a graph data structure that evolves over time, so I would like to store "snapshots" of this graph in a database. I imagine having hundreds of such snapshots.

One solution is to create a whole new table pair of nodes and edges (as above) for each snapshot. Is there a better solution?

EDIT: It was asked what I would like to do with this database. I believe that I will not be doing any querying except to dump all of the graphs to MySQL from C++ and then load it all back into C++ data structures. So I'm looking to use MySQL for storage and not for efficient random access / searching.

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

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

发布评论

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

评论(1

千紇 2024-11-13 05:53:08

您需要一个表

 graphs = (graphid, dateofsnapshot or other things unique to the snapshot)

,并且需要节点和边表,但需要有对图形表的外键引用。这样您就可以在数据库中拥有任意数量的图表。

You need a table

 graphs = (graphid, dateofsnapshot or other things unique to the snapshot)

and you need the nodes and edges tables but with a foriegn key reference to the graphs table. This way you can have an arbitrary number of graphs in the database.

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