16

I need to store dependencies in a DAG. (We're mapping a new school curriculum at a very fine grained level)

We're using rails 3

Considerations

  • Wider than it is deep
  • Very large
  • I estimate 5-10 links per node. As the system grows this will increase.
  • Many reads, few writes
  • most common are lookups:
    • dependencies of first and second degree
    • searching/verifying dependencies

I know SQL, I'll consider NoSQL.

Looking for pointers to good comparisons of implementation options.

Also interested in what we can start with fast, but will be less painful to transition to something more robust/scalable later.

Ben Sand
  • 1,130
  • 3
  • 11
  • 18

4 Answers4

15

I found this example of modeling a directed acyclic graph in SQL:

http://www.codeproject.com/KB/database/Modeling_DAGs_on_SQL_DBs.aspx?msg=3051183

Matt
  • 910
  • 7
  • 21
5

I think the upcoming version (beta at the moment) of the Ruby bindings for the graph database Neo4j should be a good fit. It's for use with Rails 3. The underlying data model uses nodes and directed relationships/edges with key/value style attributes on both. To scale read-mostly architectures Neo4j uses a master/slave replication setup.

nawroth
  • 4,321
  • 1
  • 24
  • 21
  • 2
    going with SQL to started fast, but watching Neo4j very keenly and will migrate to it within a few months – Ben Sand Nov 29 '10 at 03:38
4

You could use OrientDB as graph database. It's highly optimized for relationships since are stored as link and not JOIN. Load of bidirectional graph with 1,000 vertices needs few milliseconds.

The language binding for Rails is not yet available, but you can use it with HTTP RESTful calls.

Lvca
  • 8,938
  • 2
  • 24
  • 25
1

You might want to take a look at the act_as_dag gem.

https://github.com/resgraph/acts-as-dag

Also some good writing on Dags with SQL for people that might need some background on this.

http://www.codeproject.com/Articles/22824/A-Model-to-Represent-Directed-Acyclic-Graphs-DAG-o

Agustin
  • 1,254
  • 13
  • 10