Wednesday, April 2, 2014

Only foreign key constraints are allowed on this table - How to rectify this best practice error.

This Best practice error comes when we create a normal relation. so for that create an index for the field on which you want to create a relation, and set theAlternateKey property of the index to "Yes". Now go to this table properties and set the PrimaryIndex property to the newly created index.Now when you create a foreign key based relation on the child table it will automatically create a relationship on the field that you have set as the PrimaryIndex. so in this way you can create a normal relation through foreign key relation and you can get rid of this Best practice error.
eg.
Table1 -> Field1,Field12
Index1 -> Field1 having AlternateKey set to "Yes".
Table1 -> properties->PrimaryIndex set to "Index1".
Table2 -> create a foreign key relation (Foreign key -> Primary key based)
then automatically a reation Table2.Table1 ==Table1.Field1 is created.
In this way you can easily create a relation on any field other than RecId. and also the BP error Only foreign key constraints are allowed on this table will remove.

No comments:

Post a Comment