Best way to work with hierarchical data in Mysql for a system with constant register in the hierarchy

Asked

Viewed 426 times

1

I have a table where I store user registration where each user was indicated by another user, so I keep a column ID and a column PARENT_ID.

There are 2 ways to work with hierarchy in Mysql, are they:

  1. Adjacency List Mode
  2. Nested Set Model

I had chosen to use in my project the Nested Set Model, for having greater performance in the queries, not needing to generate a QUERY for each node when I fetch all hierarchical entries. No Nested Set Model I saw only one drawback: you need to update the values LEFT and RIGHT of all registrations when a new registration is made.

Doubt:

What is the best alternative? Lose performance when registering the user, and I will need to give a UPDATE in each register(+50000) using the Nested List Model or lose performance at the time of consultations using the Adjacency List Model?

In that case, I should use the Adjacency List Model since registrations are dynamic?

The Nested List Model would only be useful when the hierarchy is static, such as product categories?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.