StrataFrame Forum

Problems with creating Relationship

http://forum.strataframe.net/Topic22849.aspx

By Ulrik Mueller - 4/21/2009

In my current startup project on StrataFrame - i'm trying out with something very simple, but i'm getting stuck on creating a foreign key relationship between two tables.

I keep getting "There is no primary or candidate keys in the referenced table 'customer' that match the referencing column list in the forwign key 'fk_co_zip'"

BO1:  Customer - cu_number (PK), cu_name, cu_zip_number

BO2:  Zipcodes - zip_number (PK), zip_text

I'm trying to make a foreign key between cu_zip and zip_number.

I'm running on MS SQL 2005 Express Edition.

Hope that some of you can come up with the gold answer (i'm sure it is stragiht forward and simple)

Best regards

Ulrik Müller

By Trent L. Taylor - 4/22/2009

Well, if you are getting this error when you save, then this is not on the SF side.  However, in this case, it would just be a matter of opening the designer for the BO2 class (double click the BO2 class in the Solution Explorer).  There is a property called ParentRelationship.  Use the type editor (click the ellipsis button on that property) and setup the relationship between the two.  Then once you drop on an instance of each of these BOs, you will set the ParentBusinessObject property of BO2 to the instance of BO1.  That's it.  There are many samples on this including the StrataFlix sample.  There is also a lot of documentation on this as well.

If you are getting an error when you save, then there may be something going on data side.  But in regards to setting up a BO relationship, that is all that is necessary.

By Ulrik Mueller - 4/22/2009

Hi Trent

Thank you for the answer.  I'm having this problem in the DDT.  I am defining the two tables and want to define a relationship between on the ZIPCODE field.

As such this is also ok, but when I ask the DDT to deploy it to my SQL server - i'm getting the error!!!

Regards

Ulrik

By Greg McGuffey - 4/23/2009

Ulrik,



Are you deploying data also? Or is there existing data? My first guess would be that you have existing data that violates the FK. If there is existing data that currently violates the FK, you'd likely need to use a pre-script to fix this. Then the FK could be deployed with no problem.
By Trent L. Taylor - 4/27/2009

Well, you are welcome to post your PKG file so I can see the error you are facing so that we aren't missing anything.  But Greg had a valid question as well.