Foreign key generator with compound key
CHP
Posts: 6 Bronze 2
We're using SQL Data Generator 1.2. We have a table that is self-referential based on a compound key.
(In an accounting program, it's a parent-child relationship, they're accounts, and can have parent accounts within the same financial year. So, accounts have a parentID that is filled with another account's ID taken from accounts with the same FinancialYear).
When we try to generate accounts, it fails with the message: "Generation stopped. The generator for column ParentID could not generate any more values"
We've tried changing various settings and can't seem to get it to generate values for this field.
Any suggestions?
(In an accounting program, it's a parent-child relationship, they're accounts, and can have parent accounts within the same financial year. So, accounts have a parentID that is filled with another account's ID taken from accounts with the same FinancialYear).
When we try to generate accounts, it fails with the message: "Generation stopped. The generator for column ParentID could not generate any more values"
We've tried changing various settings and can't seem to get it to generate values for this field.
Any suggestions?
Comments
Thanks!
Relationships exist in the database as follows: Account table has FinYearID which is a foreign key to FinancialYear table's ID field, AccountID which is unique within the set of accounts with the same FinYearID, and ParentID which contains the AccountID of it's parent account (has the same FinYearID).
We are asking the generator to delete data from table before generation. I am asking for 100 rows in the Account table and 3 rows in the FinancialYear table. I am asking it to repeat key values between 0 and 5 times. Even though the ParentID field is marked as Allow Nulls in the database, the "Allow null values" option in Data Generator is not available. I would actually like to ask for the generator to leave the ParentID field null for most records, but it won't let me.
Do you get further if you generate more rows in the FinancialYear table? I think that there need to be more values to allow the createion of 100 unique rows in the other table that satisfy the foreign key constraint.
Here is the schema that I created to try to reproduce the date generation issue. Unfortunately I could get 3 rows into FinancialYear and 100 rows into Account.
Thank you for getting back to this. I think what was missing was the self-referencing part. Here is some sql to generate a simple version of the tables involved. LedgerID here is the ParentID I was talking about above. This should generate the error I was seeing.
The error is in the Account table: "Generation stopped. The generator for column LedgerID could not generate any more values.
Thanks for the schema snippet, it does accurately reproduce the problem. My thought is that this is bug #SDG-700, regarding self-referencing foreign keys in the same table, same problem that another user had posted here: http://www.red-gate.com/messageboard/vi ... php?t=6882
I can let you know when we take action on this issue; for now, it's still under review.