Welcome! Log In Create A New Profile

Advanced

Cardinality Headache

Posted by Hassen 
Hassen
Cardinality Headache
March 23, 2009 10:42PM
I haven't programmed in 3 years but my dad asked me to help him build an app with windev. I'm learning as I go and everything has been pretty straight forward except cardinality. I think I understand the basic concept but I can't get past this one link...
I'm attempting to write to a database using an analysis that I did not create

There is a constraint that I cannot get past

The link is...

A.autoID(1,n) to B.numeric(0,1)

What I've been doing is

A.autoID=hSetIDAuto
B.numeric=A.autoID
HAdd(cool smiley
HAdd(A)

B writes successfully but I get an error while writing A

Cardinalities related to primary key (1,-1) between <A.autoID> and <B.numeric> items are not respected.

My deadline is Wednesday and this is putting me hours behind. SOS
Al
Re: Cardinality Headache
March 23, 2009 11:13PM
Hello Hassen

If you have no access to the analysis to change it, then as a temporary measure you could try setting the integrity checking off for that file just for that operation

HSetIntegrity()

It is also probably better to write the record in File A first as it is the parent file to B and the AutoID may not have been generated.

Regards
Al



Edited 1 time(s). Last edit at 03/23/2009 11:28PM by Al.
Piet van Zanten
Re: Cardinality Headache
March 24, 2009 05:50PM
Hi Hassen,

First, I always use 0,n cardinality instead of 1,n for the master.
1,n means that the master record always has to have at least one slave record.
I can't think of any damage if a master record is hanging around without a slave.
It's impossible to add two records simultaneously, so you always have to switch off integrity checking. This is not the case for 0,n
Second, the A.autoID=hSetIDAuto line is wrong. hSetIDAuto is a constant that should only be used as a parameter in the h-functions.
You don't have to supply the autoID, as it is calculated by the hyperfile engine automatically.
So:
HAdd(A) // the autoID is calculated and stored
B.numeric=A.autoID
HAdd(cool smiley

If you cannot change the analysis:

HAdd(A,hIgnoreIntegrity)
B.numeric=A.autoID
HAdd(cool smiley

Regards,
Piet




Edited 2 time(s). Last edit at 03/24/2009 10:10PM by Piet van Zanten.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: