• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2466
  • Last Modified:

Enforce Join in Crystal report

I want to know the difference between the different types of enforce join:

-Not enforced
-Enforced From
-Enforced To
-Enforced Both
0
MKItani
Asked:
MKItani
2 Solutions
 
peter57rCommented:
If you have selected two tables for your report and have specifed a relationship between them, then the default setting is Not Enforced.

What this means is that if you only use fields from ONE of the two tables in your report then the relationship is not applied - it's as if the other table had never been included.  This can mean that you see records that you might not have been expecting to be included in the report.
If you use fields from both tables the relationship is always applied, so this setting then is irrelevant.


The complete opposite of 'not Enforced' is 'Enforced Both' - this means that even if you use fields from just one of the tables (either one) then the relationship is applied.

'Enforced from' and 'enforced to' deal with situations where you might only want the relationship enforced when one  specific table is used - either the To table for Enforced from, or the From table for 'Enforced to'.

I think the most important point is... 'If you use fields from both tables the relationship is always applied, so this setting then is irrelevant.'

0
 
mlmccCommented:
A real example

Consider an Order system

Order Table
OrderId                CustomerId                   OrderDate                  ShipDate
   1                            1                               1 May 2011               4May 2011
   2                            3                               3 May 2011               6 May 2011
   3                            4                               8 May 2011
   4                            5                               11 May 2011

Order Detail Table
OrderDetailId      fkOrderId        ProductId     Quantity        
     1                           1                   P1                2
      2                           1                  P2                 1
     3                            2                  P1                 10
     4                            2                  P4                 1
      5                           3                  P2                 1
     6                            5                  P5                 2

Customer Table
CustomerId   Name            Address            City      
     1                J Smith          11 Some St      SunCity
     2                B Jones         12 Another Ave   NewCity
     3                K Doe             15  A St             SomeCity
     5                J Doe              20 A St              Some City

  Select Order.* FROM Order INNER JOIN OrderDetail ON Order.OrderId = OrderDetail.fkOrderId

Not Enforced - 4 records are returned   - No fields from Order Detail selected so it is ignored.  Same as
Select Order.* FROM Order

Enforced       - 3 records are returned   OrderIds 1,2,3  OrderId 4 is not returned because there is no matching record in the detail table.

Enforced From - 4 records returned.  Ignored since no fields from OrderDetail selected

Enforced To - 3 records returned same as Enforced

Another example
Select OrderDetail.* FROM Order INNER JOIN OrderDetail ON Order.OrderId = OrderDetail.fkOrderId

Not Enforced - 6 records returned.  Same as Select OrderDetail.* FROM OrderDetail

Enforced   - 5 records returned.   OrderDetail 1 - 5  All have match in Order table

Enforced From - Same as Enforced

Enforced To - Same as not enforced

mlmcc

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now