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

The Archive Base Latest Questions

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

The title might be worded strange, but it’s probably because I don’t even know

  • 0

The title might be worded strange, but it’s probably because I don’t even know if I’m asking the right question.

So essentially what I’m trying to build is a “breadcrumbish” categoricalization type system (like a file directory) where each node has a parent (except for root) and each node can contain either data or another node. This will be used for organizing email addresses in a database. I have a system right now where you can create a “group” and add email addresses to that group, but it would be very nice to add an organizational system to it.

This (in my head) is in a tree format, but I don’t know what tree.

The issue I’m having is building it using MySQL. It’s easy to traverse trees that are in memory, but on database, it’s a bit trickier.


Image of tree: http://j.imagehost.org/0917/asdf.png


SELECT * FROM Businesses:
Tim’s Hardware Store, 7-11, Kwik-E-Mart, Cub Foods, Bob’s Grocery Store, CONGLOM-O

SELECT * FROM Grocery Stores:
Cub Foods, Bob’s Grocery Store, CONGLOM-O

SELECT * FROM Big Grocery Stores:
CONGLOM-O

SELECT * FROM Churches:
St. Peter’s Church, St. John’s Church


I think this should be enough information so I can accurately describe what my goal is.

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

    Well, there are a few patterns you could use. Which one is right depends on your needs.

    Do you need to select a node and all its children? If so, then a Nested set Model (Scroll down to the heading) may be better for you. The table would look like this:

    | Name     | Left | Right |
    | Emails   | 1    | 12    |
    | Business | 2    | 7     |
    | Tim's    | 3    | 4     |
    | 7-11     | 5    | 6     |
    | Churches | 8    | 11    |
    | St. Pete | 9    | 10    |
    

    So then, to find anything below a node, just do

    SELECT name FROM nodes WHERE Left > *yourleftnode* AND Right < *yourrightnode*
    

    To find everything above the node:

    SELECT name FROM nodes WHERE Left < *yourleftnode* AND Right > *yourrightnode*
    

    If you only want to query for a specific level, you could do an Adjacency List Model (Scoll down to the heading):

    | Id | Name     | Parent_Id |
    | 1  | Email    | null      |
    | 2  | Business | 1         |
    | 3  | Tim's    | 2         |
    

    To find everything on the same level, just do:

    SELECT name FROM nodes WHERE parent_id = *yourparentnode*
    

    Of course, there’s nothing stopping you from doing a hybrid approach which will let you query however you’d like for the query at hand

    | Id | Name     | Parent_Id | Left | Right | Path             |
    | 1  | Email    | null      | 1    | 6     | /                |
    | 2  | Business | 1         | 2    | 5     | /Email/          |
    | 3  | Tim's    | 2         | 3    | 4     | /Email/Business/ |
    

    Really, it’s just a matter of your needs…

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

Sidebar

Related Questions

Probably question title might looks strange for you, but I'll try to explain. I
The title might not be clear enough because I don't know how to define
The title might not be clear, but I don't know how else to put
The title might be a bit misleading, but I don't know how else to
I know that the title might sound a little contradictory, but what I'm asking
the title might be too generic, but I have a very specific question about
Hi i know the Title might sound a little confusing but im reading in
The title of this question might be confusing but the problem is simple. I'm
The title might be somewhat ambiguous, but bear with me (The only similar question
The title might been misleading, but I can´t pack my question in one sentence.

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.