Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

So I am currently working on a startup idea with a friend and we've come a long way, it's somewhat functional and I've tried to not let database design decisions slow the progress of the site. As of late I've had this feeling in my stomach I cannot sink.

The app I am building uses MySQL, I was considering PostgreSQ, but decided to stick to the aged old adage of: stick with what you know if you want to get something done quickly. The app is a social media-esque type application on the same scale as Linkedin in terms of the data that will be stored and correlated.

Many people I've spoken with have told me I should be using a graph database like Neo4j. I'm not afraid of learning new technologies, but I am afraid of getting caught up on the type of database I use in the tech stack if nobody is even using the app yet (I believe this is called premature optimisation). The current structure for friends is a simple users table and a pivot table that takes a src_id and a destination_id, this links the relationships together and it works.

I effectively want to create a circle graph network in MySQL. I want to be able to get the friends of a user, and then again the friends of that friend (3 levels deep is the maximum I would want to go). Each user has a weight score that is calculated by adding up a few meta key values from each friend of a user and that would also be info that would be pulled out in the query.

Now I know this will involve some kind of recursion, but before I go down a rabbit hole, I would like to know if MySQL can handle this kind of structure with a 3 level deep traversal of users (theoretically this could be thousands of rows, depending on the number of friends someone has)? If not, I will have no choice but to change.

share|improve this question
if the level is fixed (max to 3), then you don't need recursion. –  ypercube Jan 29 '14 at 15:12

Your Answer


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

Browse other questions tagged or ask your own question.