Skip to main content
Question

Like foreign key integrity constraint

  • November 28, 2019
  • 3 replies
  • 30 views

Forum|alt.badge.img

Hello

 

I am trying to create a control for foreign key integrity constraint between 2 tables.

it is a simple case of referenced table and referencing table. I want to check if the reference value is exiting or not.

What is the simpliest way to realize that opération ?

thanks

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • 562 replies
  • November 28, 2019

FeatureJoiner. Any features that cannot be matched because there is no corresponding value in the other table will output to one of the Unjoined Ports. It detects no matches in both directions both From and To the Lookup table. On the reference table Unjoined Port a further DuplicateFilter can be used to determine what Distinct/Unique lookup values are the ones that violate a Foreign Key constraint ie. don't exist in the Lookup table.


david_r
Celebrity
  • 8394 replies
  • November 29, 2019

If your data is already in a SQL-capable database, the fastest is to use a SQLExecutor with something like:

select *
from parent_table
where parent_table.foreign_key not in (select primary_key from child_table)

This will return all entries in "parent_table" where the attribute "foreign_key" does not reference an existing "primary_key" in "child_table". 

This is usually much faster than using the FeatureMerger or FeatureJoiner since the database will automatically leverage any existing indexes and FME does not have to copy all the data into memory first.


Forum|alt.badge.img
  • Author
  • 27 replies
  • December 2, 2019

thanks for your answers. I will try every solution