简体   繁体   English

哪种数据库体系结构适合该应用程序?

[英]what database architecture is a good choiche for this application?

I have a servlet-based application that runs in a tomcat7 environment. 我有一个在Tomcat7环境中运行的基于Servlet的应用程序。
This application needs to manage users' files in such a way these files can be accessed in many ways and through different classification methods (for instance time-oriented classification and search, keywords, tags, author and so on). 此应用程序需要以这样的方式来管理用户文件:可以通过多种方式并通过不同的分类方法(例如,面向时间的分类和搜索,关键字,标签,作者等)来访问这些文件。

So I have a multidimensional search space and I need to organize a database-based grouping system. 因此,我有一个多维搜索空间,我需要组织一个基于数据库的分组系统。

Let focus on a single and specific aspect. 让我们专注于一个特定的方面。
Any user can upload his own files. 任何用户都可以上传自己的文件。 So I'll have a path in which these files will be saved. 因此,我将在其中保存这些文件的路径。

Then I need also a place where to store the informations associated to the files. 然后,我还需要一个存放与文件关联的信息的地方。
I though that it is good to separate files from associated informaions (title, ...) and then to create a third entity that is a small string that univocally identificate both info and file. 我虽然最好将文件与关联的信息(标题,...)分开,然后创建第三个实体,该实体是一个小的字符串,可以唯一地标识信息和文件。
This way once i know the file id I can get both the informations (that are stored in a specific file) and the file but I can save this id in any perverse classification table without copying anything heavy. 这样,一旦我知道了文件ID,就可以同时获取信息(存储在特定文件中)和文件,但是我可以将此ID保存在任何不正确的分类表中,而无需复制任何内容。
So If I have the file id (fid) I can get the file and the informations. 因此,如果我具有文件ID(FID),则可以获取文件和信息。 and when I have for example to associate an object to a file I can simply associate that object to the fid. 例如,当我必须将一个对象与文件关联时,我可以简单地将该对象与fid关联。

Then any user must have its own table that collects the variuos fid of the files he uploaded . 然后,任何用户都必须拥有自己的表,该表可以收集他上传的文件的各种信息。 Therefore I have one table for each user. 因此,我为每个用户都有一张桌子。 Then for any other classification dimension I will have N tables (where N is the size of the dimension). 然后,对于任何其他分类维,我将有N个表(其中N是维的大小)。 So for instance I want to classify files for keywords, I'll need N tables each for a specific keyboard. 因此,例如,我想为关键字分类文件,每个特定键盘需要N个表。 (it will be too unefficient to search each time I want files associated to key AGAA through all the users files) So if I need to show the 50 more recent files associated to the keyword "AGAAA" I need a table for AGAAA. (每次我想要通过所有用户文件与键AGAA关联的文件时搜索效率都太低)。因此,如果需要显示与关键字“ AGAAA”关联的50个以上的最新文件,则需要一个AGAAA表。 and so on. 等等。

This is crazy. 这太疯狂了。 as the number of users increases I get exponentialy more tables. 随着用户数量的增加,我得到的表越来越多。
I heard about table limit per database in mysql databases. 我听说了mysql数据库中每个数据库的表限制。 Until now I'm using mysql (mariaDB) with connection pooling. 到目前为止,我使用带有连接池的mysql(mariaDB)。 I though to split tables of different "nature" (ie those of the keyboards, those fo the time and so on) in different databases (also in order to organize in a clearly way the contents). 我虽然在不同的数据库中拆分了不同“性质”的表(即键盘的表,时间的表等)(也是为了清楚地组织内容)。 But with connection pooling I need to declare the database name in the resource definition. 但是对于连接池,我需要在资源定义中声明数据库名称。 So for different databases I will need different pools. 因此对于不同的数据库,我将需要不同的池。

Now questions. 现在提问。

  • Using pooling I must create a different pool resource for each different database access. 使用池,我必须为每个不同的数据库访问创建一个不同的池资源。 aint I? 是不是我?
  • If yes, is It a good pratice to use the same database for all the different kind of tables? 如果是,对所有不同种类的表使用相同的数据库是否是一个好习惯?
  • If no. 如果不。 How can change database runtime? 如何更改数据库运行时?
  • I thought I could manage different tables with different database systems. 我以为可以用不同的数据库系统管理不同的表。 for example I could use SQLite in order to manage classification tables, mysql to manage user interaction and so on. 例如,我可以使用SQLite来管理分类表,使用mysql来管理用户交互等等。 Is this a good pratice? 这是一个好习惯吗?

  • Is SQLite in general faster than server-based databases in multi-user applications? 在多用户应用程序中,SQLite通常是否比基于服务器的数据库快?

  • Can I use connection pooling with SQLite ? 我可以在SQLite中使用连接池吗? I mean, what are SQLite connection if SQLite has no server? 我的意思是,如果SQLite没有服务器,则SQLite连接是什么? and does it make sense to think about connection pooling? 考虑连接池是否有意义?
  • What database architecture do you suggest for this kind of problematics? 对于这种问题,您建议使用哪种数据库体系结构?

thanks 谢谢

Why would each user or keyword need its own table? 为什么每个用户或关键字都需要自己的表? Tables can have many rows. 表格可以有很多行。

Using pooling I must create a different pool resource for each different database access. 使用池,我必须为每个不同的数据库访问创建一个不同的池资源。 aint I? 是不是我?

Your question has multiple meanings, but generally you create one pool for one application, and it manages itself. 您的问题有多种含义,但通常您为一个应用程序创建一个池,并由其自行​​管理。

If yes, is It a good pratice to use the same database for all the different kind of tables? 如果是,对所有不同种类的表使用相同的数据库是否是一个好习惯? If no. 如果不。 How can change database runtime? 如何更改数据库运行时?

Generally one would use one database for an application. 通常,一个应用程序将使用一个数据库。

I thought I could manage different tables with different database systems. 我以为可以用不同的数据库系统管理不同的表。 for example I could use SQLite in order to manage classification tables, mysql to manage user interaction and so on. 例如,我可以使用SQLite来管理分类表,使用mysql来管理用户交互等等。 Is this a good pratice? 这是一个好习惯吗?

You could, but that would be insane. 您可以,但是那太疯狂了。

Is SQLite in general faster than server-based databases in multi-user applications? 在多用户应用程序中,SQLite通常是否比基于服务器的数据库快?

Absolutely not. 绝对不。 SQLite can only have one writer at a time, though it is fine for many readers. SQLite一次只能有一位作者,尽管对许多读者来说很好。

Can I use connection pooling with SQLite ? 我可以在SQLite中使用连接池吗? I mean, what are SQLite connection if SQLite has no server? 我的意思是,如果SQLite没有服务器,则SQLite连接是什么? and does it make sense to think about connection pooling? 考虑连接池是否有意义?

I don't know, but you shouldn't use SQLite if you expect multiple concurrent users writing / uploading to the database. 我不知道,但是如果期望多个并发用户写入/上传到数据库,则不应使用SQLite。

What database architecture do you suggest for this kind of problematics? 对于这种问题,您建议使用哪种数据库体系结构?

I would suggest you use a content repository like Apache JackRabbit, or a search server like Apache Solr. 我建议您使用内容存储库(如Apache JackRabbit)或搜索服务器(如Apache Solr)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM