Tuesday, 16 February 2016

Field & Related Field Fixed Relations

Field Fixed relation
Suppose we have three tables
1) Player Table  2) Footballer 3) Cricketer
Player Table with following fields
  • PlayerName (string)
  • PlayerBenefits(string)
  • Player Type(Enum  contains Cricketer and Footballer)
FootBaller Table with following fields
  • Category (Enum contain A,B,C)
  • FootBallerCode(string)
  • Salary (real)
Cricketer Table with following fields
  • Category (Enum contain A,B,C)
  • CricCode(string)
  • Salary (real)
Here is how they all created:
Tables.jpg
Now populate some data in Footballer and Cricketer table
Second
Third
Scenario
Now For Player Table
If we select  ‘Player Type’ = Footballer then on Player Benefits field on the Player table ,lookup should be open showing the records of footballer and similiary with the case of cricketer,for this to achieve we can use the relation called ‘Fixed field’ to accomplish this.
So go to the Player table under realtion node and create a field fixed relation and here it is what I have done
Four
  • It says that  PlayterTable.PlayerType ==0(since Player Type(Enum  contains Cricketer which has a value in database equal ‘1’ and Footballer has ‘0’) you can verify by navigating to base enum and view its properties,
  • So it mean if the PlayerTable.PlayerType == Footballer then
PlayerTable.PlayerBenefits == Footballer.FootballerCode(shows the lookup of Footballer data)
And similar is the case with Cricketer see below now
Fifith
So now lets insert some data on Player table
Sixth
And
7th
Related Field Fixed
Note: below is copied from external resource
This relation restricts the records selected in the related table. Only records that meet the condition are selected.
The condition is ANDed with your relation.
Secondary table filtration can be done on the basis of relation set using related field fixed.
Example:
Primary Table:tableA(col1,col2,col3)
Secondry Table:tableB(col4,col5,col6)-col5 is an enum & can contain values 0,1,2.
tableB has 6 records as following
col4      col5     col6
1)      —           0          —
2)      —           1          —
3)      —           2          —
4)      —           1          —
5)      —           0          —
6)      —           1          —
We can set the related field fixed relation in tableA as
1==tableB.col5
It will give the lookup of 3 records of tableB i.e. 2,4 & 6th records.
Based on similar understanding I have implemented following
8th
 So we have four records in InventoryPhoneTable
9th
But when we click the look up,only showing two record
1oth

No comments:

Post a Comment