在数据库中创建百万个表? [英] create million table in a database?

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

问题描述

我想创建一个百万双列表..好,我试图创建使用java它花了大约100 mbs的数据转换为7Gbs,花了20小时来完成它...我使用postgre sql之前,我尝试mysql, mysql更糟糕。有什么办法创建这么多的表使用更少的空间和时间?
将水平分区工作得很好?



我试图索引RDF数据以便快速执行,Idea是使用rdbms索引rdf数据,并将sparql查询转换为sql查询,井RDF是三元组形式的资源集合主体,谓词,对象,现有方法使用谓词表手段,对于每个谓词,主体和对象被存储,谓词量与其他2.相比非常少。因此查询需要我试图创建主题表4快速执行

解决方案

div>

如果您的数据库中需要一百万个表,则会出错。



表用于表示结构和概念上不同的数据。我拒绝相信你在你的应用程序中运行了一百万个不同的概念。



有时,初学者相信他们应该为每个用户创建一个表。但是用户是一个概念,您为每个用户存储相同的信息(例如名称,电子邮件,用户名和密码),因此应该是一个表,其中每个用户只是一个单独的行。



听起来你犯了一个类似的错误,可能不是与用户,但与一些其他抽象,你有很多的实例。每个实例应该在一个表中的一行。



如果你向我们描述你试图存储在数据库中是什么,我们几乎可以帮助你了解如何将它映射到表。



编辑

评论(应该真正地编辑到问题本身),这里是我的想法:



如果所有的数据结构相同的方式(三元组),你可以简单地将所有内容存储在具有三列的单个表中,然后添加有效查找所需的索引。



如果提前知道所有谓词,您可以 为每个谓词创建表,但我不确定会做,甚至。



最干净的选项可能是有4个表:

(id,subject)(id,predicate)(id,object) ,objectid)。


I wanna create a million double column tables.. well I tried to create using java which took some 100 mbs of data converted to 7Gbs and took 20hrs to complete it... I am using postgre sql before which I tried mysql, mysql is even worse .. Is there any way to create this much amount of tables using less space and time? will horizontal partitioning work well ?

I am trying to index RDF data for fast execution, Idea is to index rdf data using rdbms and transform sparql query to sql query, well RDF is collection of resources in form of triples subject, predicate, object, existing methods use predicate tables means, for each predicate, subject and object are stored, amount of predicates are very less as compared to other 2. So querying requires joining of these predicate tables in order to get results which are of order of 100mbs in flat files.I was trying of creating subject tables 4 fast execution

解决方案

If you need a million tables in your database, you're doing it wrong.

Tables are intended to represent structurally and conceptually different data. And I refuse to believe that you're operating with a million different concepts in your application.

Sometimes, beginners believe they should create a table per user, for example. But "a user" is one concept, and you store the same information for each user (name, email, username, password, for example), so it ought to be one table, where each user is just a separate row.

It sounds like you're making a similar mistake, perhaps not with users, but with some other abstraction which you have a lot of instances of. Each instance should be a row in one single table.

If you describe to us what it is you're trying to store in a database, we can almost certainly help you figure out how it should be mapped to tables.

Edit
after reading your comments (which should really be edited into the question itself), here are my thoughts:

If all the data is structured the same way (as triples), you could simply store everything in a single table with three columns, and then add the necessary indexes for efficient lookups.

If all the predicates are known in advance, you could make a table per predicate, but I'm not really sure how much sense that would make, even.

The cleanest option would probably be to have 4 tables:
(id, subject), (id, predicate) , (id, object),(subjectid, predicateid, objectid).

这篇关于在数据库中创建百万个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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