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 599481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:30:12+00:00 2026-05-13T16:30:12+00:00

An example of my tree table is: ([id] is an identity) [id], [parent_id], [path]

  • 0

An example of my tree table is: ([id] is an identity)

[id], [parent_id], [path]

1, NULL, 1

2, 1, 1-2

3, 1, 1-3

4, 3, 1-3-4

My goal is to query quickly for multiple rows of this table and view the full path of the node from its root, through its superiors, down to itself. The ultimate question is, should I generate this path on inserts and maintain it in its own column or generate this path on query to save disk space? I guess it depends if this table is write heavy or read heavy.

I’ve been contemplating several approaches to using the “path” characteristic of this parent/child relationship and I just can’t seem to settle on one. This “path” is simply for display purposes and serves absolutely no purpose other than that. Here is what I have done to implement this “path.”

  1. AFTER INSERT TRIGGER – requires passing a NULL path to the insert and updating the path for the record at the inserted rows identity
  2. INSTEAD OF INSERT TRIGGER – does not require insert to have NULL path passed, but does require the trigger to insert with a NULL path and updating the path for the record at SCOPE_IDENTITY()
  3. STORED PROCEDURE – requiring all inserts into this table to be done through the stored procedure implementing the trigger logic
  4. VIEW – requires building the path in the view

1 and 2 seem annoying if massive amounts of data are entered at once.

3 seems annoying because all inserts must go through the procedure in order to have a valid path populated.

1, 2, and 3 require maintaining a path column on the table.

4 removes all the limitations of the above but require the view to perform the path logic and requires use of the view if a path is to be displayed.

I have successfully implemented all of the above approaches and I’m mainly looking for some advice. Am I way off the mark here or are any of the above acceptable? Each has it’s advantages and disadvantages.

  • 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-13T16:30:13+00:00Added an answer on May 13, 2026 at 4:30 pm

    “It depends” sure applies to this one. There are so many possibilities, its just not possible to name The Best One. Here’s a handful of ideas.

    How often is new data added? Can data be modified (or items deleted) such that a hieararchical “chain” changes? How much data/how big is the table? How will you be using the data? How important is it to be up-to-date? All of these lead to different possible implementations, based on performace requirements.

    We have a similar setup in a data warehouse. The data gets entered in controlled ETL batches, so we have the luxury of feeding it through a stored procedure to properly determine and load the “path” column, and then we never worry about it again.

    Barring strong reasons not to, I’d go with the stored procedure implementation, if only because the code can get a bit tricky. If you cannot control people inserting/updating/deleting [I originally wrote “monkeying”] with the data outside of the stored procedure, then I’d think you have security issues. If the data can be inacurate or out of date for short periods of times, you could have a scheduled routine that regularly checks and recalibrates entries (either new unset items, or recheck everything for modifications.)

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

Sidebar

Related Questions

I have a table similar to this: CREATE TABLE example ( id integer primary
Could you provide an example of accessing the Eclipse Abstract Syntax Tree programmatically for
Lately I've be moving source files around in our source tree. For example placing
I'm looking for examples of specifying files in a tree structure, for example, for
I have a parent/child table (simple tree) table structure (ID, ParentID), where I want
Given a table that represents a hierarchical tree structure and has three columns ID
I have a table in my database where I store a tree structure using
We have a general organizational table structure, think of it s a Tree or
Let's just say I have tree in my table called page: Foo -- Bar
I have a table in a relational database, in which I encode a tree

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.