NoSQL Zone is brought to you in partnership with:

Max De Marzi, is a seasoned web developer. He started building websites in 1996 and has worked with Ruby on Rails since 2006. The web forced Max to wear many hats and master a wide range of technologies. He can be a system admin, database developer, graphic designer, back-end engineer and data scientist in the course of one afternoon. Max is a graph database enthusiast. He built the Neography Ruby Gem, a rest api wrapper to the Neo4j Graph Database. He is addicted to learning new things, loves a challenge and finding pragmatic solutions. Max is very easy to work with, focuses under pressure and has the patience of a rock. Max is a DZone MVB and is not an employee of DZone and has posted 59 posts at DZone. You can read more from them at their website. View Full User Profile

Relationships and Relational Databases

  • submit to reddit

When working with relational databases, the join tables are sometimes treated as second class citizens. If they are lucky, they’ll get some additional fields, but are often just placeholder tables connecting your main object tables together. It leads you to think about objects first, and relationships second. With graphs, you will want to switch up your thinking. You want to start thinking about how things are connected. Think about the different ways things are connected. Two people can be friends, co-workers, and neighbors all at the same time.

If you’ve ever been crazy enough to go back to school after your bachelor’s degree, you know all about research papers, journals, and citations. So what kind of relationships can we find here? Papers are rarely authored alone. Having multiple authors means you can create a graph of co-authors. Which students and scientists work together on papers, and which should work together. Scientific research builds upon the work of others, and previous work can be used to build a graph of citations. Keywords in the abstracts or extracted from the papers can be used to build a graph of similar content.

What about a social network like Twitter? How about a Follower graph, a Reply graph, a Mention graph, a Co-Listed graph, a HashTag graph, a Co-Location graph, a Shared-URL graph? What about blogs? How about a Link graph, a Blogroll graph, a Tag graph?

You will be surprised by how connected your data is once you start exploring it. Don’t be afraid of your model. Just start with whatever you have and start adding nodes and relationships as they become apparent to you. Your model will probably evolve, so don’t waste your time second guessing yourself.

When folks ask me about modeling, I tell them to start with the questions they want to answer. It doesn’t end there however. Once you’ve answered those questions, you’ll discover more. You’ll say, if I had this extra piece of data, I could ask and answer a ton new questions I didn’t think about before.

I’ll spend some time in the next few posts digging in a little deeper.

Published at DZone with permission of Max De Marzi, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)