Recrd-ImplicitDatasetRel.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="Implicit_Dataset_Relationality">
  5. <title>Implicit Dataset<indexterm>
  6. <primary>Implicit Dataset</primary>
  7. </indexterm> Relationality<indexterm>
  8. <primary>Relationality</primary>
  9. </indexterm><indexterm>
  10. <primary>Implicit Dataset Relationality</primary>
  11. </indexterm></title>
  12. <para>Nested child datasets<indexterm>
  13. <primary>Nested child datasets</primary>
  14. </indexterm> in a Data Refinery (Thor) or Rapid Data Delivery Engine
  15. (Roxie) cluster are inherently relational, since all the parent-child data
  16. is contained within a single physical record. The following rules apply to
  17. all inherent relationships.</para>
  18. <para>The scope level of a particular query is defined by the primary
  19. dataset for the query. During the query, the assumption is that you are
  20. working with a single record from that primary dataset.</para>
  21. <para>Assuming that you have the following relational structure in your
  22. database:</para>
  23. <programlisting> Household Parent
  24. Person Child of Household
  25. Accounts Child of Person, Grandchild of Household</programlisting>
  26. <para>This means that, at the primary scope level:</para>
  27. <para>a) All fields from any file that has a 1:M relationship with the
  28. primary file are available. That is, all fields in any parent (or
  29. grandparent, etc.) record are available to the child. For example, if the
  30. Person dataset is the primary scope, then all the fields in the Household
  31. dataset are available.</para>
  32. <para>b) All child datasets (or grandchildren, etc.) can be used in
  33. sub-queries to filter the parent, as long as the sub-query uses an aggregate
  34. function or operates at the level of the existence of a set of child records
  35. that meet the filter criteria (see EXISTS).You can use specific fields from
  36. within a child record at the scope level of the parent record by the use of
  37. EVALUATE or subscripting ([]) to a specific child record. For example, if
  38. the Person dataset is the primary scope, then you may filter the set of
  39. related Accounts records and check to see if you've filtered out all the
  40. related Accounts records.</para>
  41. <para>c) If a dataset is used in a scope where it is not a child of the
  42. primary dataset, it is evaluated in the enclosing scope. For example, the
  43. expression:</para>
  44. <para><programlisting>Household(Person(personage &gt; AVE(Person,personage))</programlisting></para>
  45. <para>means “households containing people whose age is above the average age
  46. for the household.” It does <emphasis role="underline">not</emphasis> mean
  47. “households containing people whose age is above the average for all the
  48. households.” This is because the primary dataset (Household) encloses the
  49. child dataset (Person), making the evaluation of the AVE function operate at
  50. the level of the persons within the household.</para>
  51. <para>d) An attribute defined with the STORED() workflow service is
  52. evaluated at the global level. It is an error if it cannot be evaluated
  53. independently of other datasets. This can lead to some slightly strange
  54. behaviour:</para>
  55. <programlisting>AveAge := AVE(Person,personage);
  56. MyHouses := Household(Person(personage &gt; aveAge));</programlisting>
  57. <para>means “households containing people whose age is above the average age
  58. for the household.” However,</para>
  59. <programlisting>AveAge := AVE(Person,personage) : STORED('AveAge');
  60. MyHouses := Household(Person(personage &gt; aveAge));</programlisting>
  61. <para>Means “households containing people whose age is above the average for
  62. all the households.” This is because the AveAge attribute is now evaluated
  63. outside the enclosing Household scope.</para>
  64. </sect1>