Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6056771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:24:51+00:00 2026-05-23T08:24:51+00:00

What issues are associated with maintaining multiple tress within a single table? The motivation

  • 0

What issues are associated with maintaining multiple tress within a single table?

The motivation for having multiple trees is to avoid excessive updates to all nodes when inserting a node at the start. Each of the trees are completely separate entities.

Example Table:

tree_id  | id  | lft | rgt | parent_id |   various fields . . .
---------------------------------------------------------------------
1        |  1  |  1  |  4  |   NULL    |   ...
1        |  2  |  2  |  3  |    1      |   ...
2        |  3  |  1  |  4  |   NULL    |   ...
2        |  4  |  2  |  3  |    3      |   ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:24:51+00:00Added an answer on May 23, 2026 at 8:24 am

    It’s very common to store multiple trees in one table, just have to make sure the values that comprise a tree are stored correctly, otherwise it’ll lead to data integrity issues like nonsensical tree constructions.

    Suppose we have a binary tree, (like the one in your example). If a tree was 5 depth. ((2^n)-1) = (2^5 – 1) nodes would exist or 31 rows in the database which is trivial. Even at 10 depth it’s still a small amount of rows, but would be a rather ginormous tree. And so having multiple trees, X, in there would be X((2^n)-1) = rows… in the database which isn’t bad. So potentially a hundred trees could exist in one table and would only be 100k rows which is relatively small.

    Additionally, suppose every new tree constructed was stored in its own table, then very quickly, the database would be filled with quite a bit of tables over time to match the number of trees that exist. And it just seems like not a good idea to make extra tables that are unneeded, adds unneeded complexity in the code side to have to access these multiple tables.

    Looking at your table in detail, it doesn’t quite look right in terms of columns, but I’m sure that table example is just something thrown up quickly to show us what you mean.

    tree_id, node_id, left_node_id, right_node_id, various_fields...
    

    Um, be sure to index those _id fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having issues referencing $(this) from within a the nested ajax 'success' function... I know
I'm having issues creating an ActionLink using Preview 5. All the docs I can
I'm having issues with my SQL Reporting Services reports. I'm using a custom font
I'm having some issues with producing an int matrix without creating memory leaks. I
What are the performance issues associated with generating 100's of dynamic methods in Ruby?
This question has no practical issues associated with it, it is more a matter
I would like to know the performance issues associated with running managed code through
I'm wondering if there are any negative performance issues associated with using a Singleton
We are having some major performance issues with SELECT queries out one of our
I am having some difficulty understanding callbacks and program flow, synchronization issues. Lets say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.