Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Rails 4 app having to do with graphs. These graphs need to be stored and I'm not sure of the best way to do it. Firstly, the app has a SQLite db in development and PostgreSQL in production. I would love to have graphs in JSON, but that can be achieved in several ways. Also, these graphs are going to be manipulated using some interface. I was thinking a graphical solution and a raw one in JSON.

I have some alternatives to implementation:

  1. Store the graph JSON files directly in the db. (how?)
  2. Store the graphs in db with tables (graph, edges, vertex) (probably not...)
  3. Store the graphs in db with tables and build a parser to manipulate the in JSON format.

What is your recommendations?

share|improve this question
Where is your question? – tjons Sep 4 '13 at 15:50
Let me spell it out for you ;-) – mfaerevaag Sep 4 '13 at 15:55
The recommendation thing was not there earlier. Or, I just missed it ;) – tjons Sep 4 '13 at 15:59
up vote 2 down vote accepted

It looks like you're talking about mathematical graphs, not charts per se. I read a pretty nice presentation on using Postgres for storing graph-type data. It covers several different data modeling options that can work with an RDBMS. You might also want to consider using a specialized graph database (neo4j) for graph-related needs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.