如何在数据库中存储大列表 [英] How can I store a large list in a database

查看:102
本文介绍了如何在数据库中存储大列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库中存储大量URL,每个列表都有一个ID,并且两个不同列表中的URL很可能不相同,这意味着不同URL列表之间的交集很小。列表的大小是未知的,并且每个列表的大小都不相同。

I want to store a large list of urls in a database, each list has an Id and the urls in two different list are most likely not the same, meaning that there is very small intersection between to different list of urls. The size of the list is not know and vary from one list to the other.

当前,我将列表作为字符串存储在PostgreSQL数据库的字段中,我知道这不是一个好的解决方案,所以我正在寻找更好的解决方案。

Currently, I am storing the list as a string in a field of a PostgreSQL database, I know it is not a good solution so I am looking for a better one.

我想到的是:


  • 将每个url存储在单独的表中,并以一对多关系链接它们。我认为这种解决方案不是很好,因为正如我所说的那样,URL可能只会出现在一个列表中。

  • 选择一些NoSQL解决方案(mongoDB),但是我从未尝试过这,我想看看你们是否有更好的解决方案。

谢谢您的回答。

推荐答案

您应该在两个表列表和 URL之间建立多对多关系

You should make a many-to-many relation between the two tables "lists" and "urls"

这篇关于如何在数据库中存储大列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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