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

The Archive Base Latest Questions

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

I have a data structure consisting of a set of objects which are arranged

  • 0

I have a data structure consisting of a set of objects which are arranged into a multiply-linked list which is also (isomorphically) a valid DAG. It could be viewed as one single multiply-linked list, or as a series of n doubly-linked lists which may share members. (This is the same data structure from Algorithm for quickly obtaining a partial ordering over multiple linked lists, for those of you following my questions.)

I am looking for a general technique, in no specific SQL dialect, for expressing this multiply-linked list/DAG in SQL, such that it’s easy to take a given node and obtain:

  • The previous and next links in the DAG, given a topological ordering of the DAG
  • The previous and next links in each doubly-linked list to which this node belongs

Using the example data from that other question:

first  = [a, b,    d,    f,    h, i];
second = [a, b, c,       f, g,    i];
third  = [a,          e, f, g, h, i];

I’d want to be able to, given node f, obtain [(c|d|e), g] from the overall DAG’s topology and also {first: [d, h], second: [c, g], third: [e, g]} from each of the lists orderings.

Here’s the fun part: n, the number of doubly-linked lists, is not fixed and may grow at any time. I’d rather not redo the schema each time that happens.

All of the algorithms I’ve come up with so far either (a) stuff a big pickle into the DB and pull it out in order to calculate orderings, or (b) require that the lists be explicitly enumerated as recursive relations in the DB.

I’ll go with an option in (b) if I can’t find something better but I’m hoping that there’s something magical out there to make this easier.

  • 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-23T05:24:08+00:00Added an answer on May 23, 2026 at 5:24 am

    Pre:
    This is a question and answer forum, not ‘lets sit down, group think for a bit, and solve the whole problem’ forum.

    I think what you want to investigate in a technique called ‘modified preordered tree traversal’ a mouthful i know, but it allows the storing of hierarchical data in a flat database and individual enties. Sadly, you do have to do some rewriting on inserts, but the selects can be done in a single query, so it’s best for ‘many view/ few changes’ situations like a website. Luckily, you rarely have to rewrite the whole dataset (only the parts you changed and those hierarchically after them.

    I remember a good article on the basics on it ( a couple years ago) but can’t find the bookmark atm, so start with just a google search.

    EDIT/UPDATE:

    link: http://www.sitepoint.com/hierarchical-data-database/

    No matter what, from dealing with this issue extensively, you will have to choose were to put the brunt of the work, on view, or on change. Depending on the size of the ‘master’ tree, you may (like me) decide to break the tree up into parts and use a tree of trees, limiting the update cost.

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

Sidebar

Related Questions

I have a data structure which uses composite ids (Which I dont wish to
I have a data structure which is as given below: class File { public
Guys, I have a data structure which has 25 distinct keys (integer) and a
I have the following data structure (a list of lists) [ ['4', '21', '1',
I have a simple record structure consisting of a header (H) and a list
I have a data structure which is a collection of tuples like this: things
I have data like A=B&C=D&E=F How to quickly parse it into a data structure
I have data structure which stores POD-structs (each instantiation stores a single type only,
I have huge amont of geographic data represented in simple object structure consisting only
I have a data structure that represents C# code like this: class Namespace: string

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.