2 Replies Latest reply on Mar 12, 2010 10:03 AM by comment_1

    Tree-structure in one table



      Tree-structure in one table




      I’m pretty new to filemaker, and databases in general, so perhaps my question isn’t making any sense, but here goes anyway:


      I have a database over a number of ideas, it’s structured in one table. I would like to implement some kind of tree-structure, where every idea knows it’s father-idea, or from what idea it came. For now i have a field, where the user inserts the name of the father-idea in every idea-record.


      Furthermore i need to present all the related ideas, meaning that all ideas who are related in any kind(brother, father, son, grandson, grandfather and so on) will be presented in one search or in one list.

      I have worked a bit with some sort of script, trying to loop through the records, but i have a hard time understanding exactly how. I need to store found records and use data from those, to be able to search further on.


      I don’t know if it’s the wrong way to do it, or if it’s even possible or if it’s completely gibberish, but please let me know.


      Filemaker pro 10

      Mac OSX 10.5.8

      FM-exp: close to none

        • 1. Re: Tree-structure in one table



          I'd add an addition table that links your various records in order to produce your tree structure. A portal to that table can then list related idea records.


          Something like this might work:


          A new table, RelatedIDeas, would have at least two fields: ParentIdeaID, ChildIdeaID


          You'd define a relationship between your two tables as:


          MainTable::IdeaID = RelatedIdeas::ParentIdeaID (Select "Allow creation of records via this relationship" for RelatedIdeas.)


          You can then select the MainTable table occurrence box in the relationship graph and click the button with two plus signs to make a second table occurrence of it. Name it ChildIdeas and link it to RelatedIdeas like this:


          ChildIdeas::IdeaID = RelatedIdeas::ChildIdeaID


          Now you can place a portal to RelatedIdeas on your main table's layout and add fields, such as the name of the idea from ChildIdeas to your portal. You can reverse the process by creating a layout based on ChildIdeas and put fields from MainTable in your RelatedIdeas portal.



          • 2. Re: Tree-structure in one table

            This is not an undertaking I would recommend to a beginner. Perhaps you should start by reading:






            If every idea has ONE parent idea, then there's no need for additional tables.