6 Replies Latest reply on Oct 29, 2014 10:16 AM by philmodjunk

    Context versus Relationship



      Context versus Relationship


      Is there a difference between "Context" and "Relationship" or are they synonymous ?

      Is it accurate to describe the "context" as a query or filter that shows records from Table B that meet the criteria defined in its relationship to Table A?


        • 1. Re: Context versus Relationship


          Context is the table in the relationships graph from which a relationship is evaluated. When you define a calculation in a source table, and the table has more than one occurrence in the relationships graph, you must specify the context from which you want the calculation to evaluate.
          Each context choice represents a different table in the relationships graph, and a different perspective into your data; when you choose the context for a calculation, you tell FileMaker Pro to evaluate the calculation starting from that table occurrence. Because each context choice represents a different association of related tables and fields, choosing the evaluation context for your calculation is critical to getting the results you expect.
          • 2. Re: Context versus Relationship

            Thank you, David. 

            I'm sure your explanation is technically accurate but it's still a bit too abstract. I understand that TO'S are not tables and that the relationship graph can have multiple instances of the same table, including itself.

            Was my description of context in the first post of this thread incorrect?

            An example of how the evaluation context is so important for a calculation would help. 

            Thanks again for taking the time to help.

            • 3. Re: Context versus Relationship

              Go back and review this tutorial on table occurrences: Tutorial: What are Table Occurrences?

              A relationship describes the link between two table occurrences. It's the rules on how records in one of the two tables match to records in the other. Example. Table1::SerialNumberField = Table2::NumberField. The "rule" here is that any records in Table2 That have a value in NumberField = to the value of SerialNumberField of a record in Table 1 are related to that record.

              Context describes the "starting point" from which relationships are evaluated. If you are on a Layout based on Table1 your "context" is whatever record from Table1 is your current record. The value of SerialNumberField for that record will be used by the above relationship to determine which records in Table 2 are related to it and thus can be displayed in a portal.

              But if you change your context to a layout based on table 2, you turn the above relationship around. Whatever record you are on, it's NumberField value can match to only one record in Table 1. A portal to Table1 could only show one record. Same relationship, different context.

              • 4. Re: Context versus Relationship

                edit: Phil beat me to it (with a better answer to boot ofc smiley)

                Using your way of describing it, if relationships are "filters", context (which is specified in the calculation editor) specifies *which* filter by explicitly defining "from where" the calculation is defining itself in the relationship graph.  Consider these 2 relationships among 3 TO's (A_1, A_2, and B_1 based on 2 tables (A and B) using a number field from each table


                A calculation field in table A which is simply equal to the number field in B will return the first result across the relationship.  If the context of the calculation is A_1 than this will be the first number greater than the value of A_1::number in the record you are viewing.  In the context of A_2 this will be the first number less than A_1::number.  (Order (ie which is 'first) depends on the relationship's sort order which defaults to creation order ascending).

                For example if table b has ten records in which the number field takes, successively, the numbers 1-10 and in your current record based on table A the number field equals 5, then the aforementioned calculation field in table A will equal either 4 or 6 depending on the context you have chosen (assuming both relationships are sorted by the value of B::number).

                A pair of binoculars has only one 'relationship'- that is, through the lens.  But depending on your context (through the smaller or larger aperture) you get very different views.

                • 5. Re: Context versus Relationship

                  Thank you Phil and Nihm for both of your answers and examples. Both were very helpful.

                  • 6. Re: Context versus Relationship

                    I rather liked the Binoculars analogy.