Whats the right Database System for this

空扰寡人 提交于 2019-12-24 10:01:36

问题


For an application written in Scala I'm looking for the 'best' database system for the following requirements:

  • Good support for queries like: For a node find all connected nodes, all nodes connected via another node with value 'somevalue'
  • Available as a cloud service for 0$ for low volumes of data
  • Good community support and documentation

回答1:


Most probably you are trying to store a graph on your database.

There are graph databases especially created for storing nodes and connecting nodes with vertices (in your terms, values). http://en.wikipedia.org/wiki/Graph_database#Graph_database_projects

I'm afraid, there are no free options offered in the cloud for free. You should buy a VPS, Amazon EC2 instance, Windows Azure instance or whatsoever to host your database. Nothing comes free these days.

Among the graph databases, my choice would be neo4j, it has a good support, documentation, community and it is especially designed for usage with Java (and Scala, of course). However I heard that orientdb and vertexdb are also good for that.




回答2:


Good support for queries like: For a node find all connected nodes, all nodes connected via another node with value 'somevalue' Good community support and documentation

Postgres is quite adequate if you only need to find nodes within a neighborhood, in that it supports recursive queries.

Assuming you've an oriented graph of nodes (id, parent_id, col), this allows to write:

with rec_nodes as (
select id,
       col,
       1 as depth
from   nodes
where  parent_id = :id
union all
select nodes.id,
       nodes.col,
       rec_nodes.depth + 1 as depth
from   nodes
join   rec_nodes on rec_nodes.parent_id = nodes.id
where  depth < :depth
)
select id
from   rec_nodes
where  col = :col;

The above will perform very well as long as the :id and :depth constraints are within the with statement (when not, it'll build the whole graph, and you definitely don't want that to occur).

Available as a cloud service for 0$ for low volumes of data

Not cloud, nor $0, but very cheap here. (Last I checked, the basic VPS offered Postgres on a shared server. And the whole thing is run by one of the Postgres founders.)

Be wary when hosting a DB in the cloud directly.



来源:https://stackoverflow.com/questions/6317044/whats-the-right-database-system-for-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!