Krishna Bharadwaj
Krishna Bharadwaj

Reputation: 625

Is MPTT an overkill for maintaining a tree like database even if the depth is around 3 - 4?

I am planning to store some tree like data in MySQL.
Topics can have sub topics and they in turn can have more sub topics.
Is Modified Preorder Tree Traversal(MPTT) an over kill even if the maximum depth is around 3 - 4?

Upvotes: 5

Views: 433

Answers (1)

Sergei
Sergei

Reputation: 390

In any way you have to write model methods like get_children(), get_root(), is_root() and others. In some cases django-mptt will reduce queries to database. It is not overkill, it will save you a lot of time. django-mptt code is more reliable than yours will be, so you code will have less potential bugs. Just spend a few hours to read full docs=)

Upvotes: 1

Related Questions