Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Hierarchical data in db

General discussions related to php

Moderators: macek, egami, gesf

Hierarchical data in db

Postby faust » Thu Jan 24, 2013 7:30 am

I thought a lot about this, searched the internet and the method that I like most is where you keep the lineage in a separate field in your table containing your hierarchical data. I'm not saying it's the best, just that I like it best. I'll explain the method quickly and then ask my question.
You have a table structure like this:
Code: Select all
id INT
title VARCHAR
parent_id INT
lineage VARCHAR

In the lineage field we keep the lineage of the current item with the id's of it's parents separated by unique separator(ex. 1/=/4/=/7). In the example item with id of 1 is the main item, it's child is with id 4 and it's grandchild is with id 7. So far, so good. Everything's working okay - insert, edit, delete.
But what is the best way to visualize this for the user? Noone will understand 1/=/4/=/7. I have to replace the id's with their corresponding title (ex. Category1->Category4->Category7).
Hope I explained everything clear. Need your help. Cheers !
faust
New php-forum User
New php-forum User
 
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Re: Hierarchical data in db

Postby faust » Fri Jan 25, 2013 7:15 am

anyone?
faust
New php-forum User
New php-forum User
 
Posts: 109
Joined: Thu May 03, 2012 7:22 am


Return to PHP General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.