Skip to main content
Open

Add a checkbox to the software factory reference popup to set the reference as No Check

Related products:Software Factory
  • January 28, 2020
  • 4 replies
  • 91 views

Michael
Thinkwiser
Forum|alt.badge.img+4

The option no-check on references is something that we could use when applying a reference on a table that contains historic data from a old-application.

For example you can only migrate the headings of invoices to the new system but no invoice lines. You do want that new invoices created in the system you are creating has a check constraint that is validated. But for old-data you want it not to apply. For this reason SQL implemented the No Check option on references… 

What i would like to see is a checkbox on the reference box where you can set the reference to be as a No Check reference. 

Why do i want this? Well i've seen many projects where people just toggle of the Integrity check on the reference. But do not consider that database could get corrupted when something goes wrong. Fixing missing data is harder dan solving the problem when the check constraint gives an error.

4 replies

Michael
Thinkwiser
Forum|alt.badge.img+4
  • Author
  • Thinkwiser
  • January 28, 2020

To be clear, i mean the reference popup in the datamodeler


Frank Wijnhout
Thinkwise blogger

Hey Michael, as far as I know SQL Server is not capable of checking data on referential integrity for new data only. The NOCHECK option in fact kind of disables the constraint for all data. I don't think that is what you want.

What you can do is change your reference into a GUI-reference (check is off) and add some code into your triggers to enforce integrity for new records.

 

 

 


Michael
Thinkwiser
Forum|alt.badge.img+4
  • Author
  • Thinkwiser
  • January 30, 2020

Hey Michael, as far as I know SQL Server is not capable of checking data on referential integrity for new data only. The NOCHECK option in fact kind of disables the constraint for all data. I don't think that is what you want.

What you can do is change your reference into a GUI-reference (check is off) and add some code into your triggers to enforce integrity for new records.

 

WITH CHECK will check existing data against the new constraint.
WITH NOCHECK will not check existing data against the new constraint. This will allow you to have child records without a corresponding parent.

I believe SQL Server is capable ;-)


Frank Wijnhout
Thinkwise blogger

Michael, I tested it and you are right. SQL Server is capable :)