3 Replies Latest reply on Aug 27, 2013 2:16 PM by philmodjunk

    child tables inside parent table



      child tables inside parent table


           I need to add function of viewing the history of each record in my db (date, comment, mb smth else that will be managed manually and automatically (e.g. date)).

           Now I see only one way to do this: to create separate table for each record. However I'm not sure if it is a good idea and moreover I do not know if it is possible to script this (creating table for each record).

           Also I though about creating many additional fields directly to the records in my db and then write history records there, however it is not a good idea either: history records will be limited to number of additional fields and it will be necessary to create tons of additional fields.

           Any suggestions how can I realise this?

        • 1. Re: child tables inside parent table

               Don't create a separate table for each work. That won't work. But with this relationship:

               ParentTable::__pkParentID = ChildTable::_fkParentID

               you can set up a portal to ChildTable on your ParentTable layout and be able to see/edit/create/delete child table records in the portal and you will only see those records that are linked to the current parent table record.

          • 2. Re: child tables inside parent table

                 hmm..little bit hard to understand how to set up such relationship. 

                 Im currently reading about relationships and portals. Would be great if you can explain how to set up this to see linked records on the other table layout.

            • 3. Re: child tables inside parent table

                   __pkParentID should be defined to auto-enter a serial number

                   Open Manage | Database | Relationship.

                   Drag from ParentTable::__pkParentID to ChildTable::_fkParentID

                   Double click the relationship line this creates.

                   In the dialog this action opens, click the checkbox for "allow creation of records via this relationship" on the ChildTable side.

                   Click OK and use the portal tool to draw rectangle on your layout where you want a portal.

                   Select ChildTable in Show Related Records From, select the portal options that you want and click OK.

                   Then select the fields that you want to see in your portal from ChildTable.

                   Return to browse mode and you can now create new records in ChildTable by entering data in the blank bottom "Add" row. This is possible because you selected "allow creation..." for the child table in this relationship. WHen you enter data in the add row, FileMaker automatically copies the value of __pkParentID from the current record to the _fkParentID field in the the new ChildTable record.