Hi Martin,
You are talking about standard Parent/Child relationships here but because you have 
unlimited number of entries you fold it into one table and have a Parent_ID column.  
So if you have your required details as being these columns

Name
SomethingElse

Then a standard table might be 

Name_ID
Name
Somethingelse

adding the parent id column would be

Name_ID
Name
Somethingelse
Parent_ID

or
Create Table TableName (
Name_ID INTERPER PRIMARYKEY , 
Name , 
Somethingelse , 
Parent_ID )

Now all you need to do is fill in the details , PARENT_ID = 0 means it has no parents 
(or leave it NULL if you want) 
When you retrieve the rows you always do select * from Tablename where Parent_ID = 2 
(or what ever)

regards
Greg O


  ----- Original Message ----- 
  From: John Scott 
  To: [EMAIL PROTECTED] 
  Sent: Monday, January 19, 2004 9:52 AM
  Subject: [sqlite] Best method to create a database with a tree structure?




  Hello folks,

  I am thinking of to create a database with a tree structure.

  BUt it seems to be a hard work. 

  I would like to have a tree structure embbeded into the database like:

  Root folder which contains two other folders "books" and "music".

  If a click on books, only the entries in the database which belong to the folder 
bools under root should be displayed.

   

  Does someone have a good idea??

  Thanks,

  Martin



  ---------------------------------
  每天都 Yahoo!奇摩 
  海的顏色、風的氣息、愛你的溫度,盡在信紙底圖
  信紙底圖

Reply via email to