StrataFrame Forum

Relationship Creation Error

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

By Ozzie Seda, Jr - 10/6/2006

I'm trying out the demo of the DDT and when I create a relationship between 2 tables and go to deploy to server I get the following error:

Creating relationship 'FK_relationship' failed.
Create failed for ForeignKey 'FK_relationship'.
An exception occurred while executing a Transact-SQL statement or batch.
Foreign key 'FK_relationship' references invalid table 'master table'.
Could not create constraint. See previous errors.

There are no previous errors.  I'm using SQL Server Express.  I've tried setting the relationship from both tables as parent child, child parent with the same results.

Any ideas?

Thanks,

Ozzie

By Trent L. Taylor - 10/6/2006

Well, the error is actually coming from SQL Server because the defined relationship cannot be established.  To better help you I need a couple of things.  I need the structure of the parent and child (at least the primary keys and the foreign key fields) and how you have defined the foreign key relationship (and which table you defined this on).

Also, what master table reference is being made here?  Is this a table in your database named master?

By Ozzie Seda, Jr - 10/6/2006

Here's what I'm trying to accomplish...nothing out of the ordinary.

Ozzie

By Ozzie Seda, Jr - 10/6/2006

Also, I tried defining the relationship on each table individually, after deleting all tables and every thing on SQL Express, and still the same result.

Ozzie

By Ozzie Seda, Jr - 10/6/2006

Creating relationship 'FK_Trade_TradeDivision' failed.
Create failed for ForeignKey 'FK_Trade_TradeDivision'.
An exception occurred while executing a Transact-SQL statement or batch.
Foreign key 'FK_Trade_TradeDivision' references invalid table 'Trade'.
Could not create constraint. See previous errors.

This is the message when I create the relationship on table 'Trade'.

When I create the relationship on table 'TradeDivision' I get the same message as above except it references invalid table 'TradeDivision'

Thanks

Ozzie

By Trent L. Taylor - 10/6/2006

Then this is what you will do.  Make sure that all of your foreign keys are removed from the Trade and TradeDivision tables (just to start over).  Once this is done do the following:

  1. Select the TradeDivision table
  2. Open the Relationships Item underneath the TradeDivision table
  3. Create a new relationship
  4. Name the item something like Fk_TradeDivision_Trade
  5. Select the TradeDivisionID field for the parent
  6. Select the Trade table from the bottom combo
  7. Select the TradeDivisionID field on the bottom right combo
  8. If you already have data in the table that will break the relationship, you can turn off the Ensure data checkbox (top check)
  9. Set any cascade details
  10. Click OK
  11. Rebuild your package and redeploy
By Trent L. Taylor - 10/6/2006

Try the last post I made and see if it will succesfully create the relationship.  If not, create your package file and post it as an attachment here and I will fix it and send it back to you so you can see how to create the relationship.
By Ozzie Seda, Jr - 10/6/2006

Attached is the pkg file.  I tried what you suggested on your last post, didn't work.

Ozzie

By Trent L. Taylor - 10/6/2006

Ozzie,

I will look at this some more.  I am having a hard time making this work in SQL Server (aside from the DDT).  There is a SQL Server rule that is being violated and I am going to have to take a closer look.  It will more than likely be Monday before I get back to you on this.

By StrataFrame Team - 10/9/2006

There was an error within the DBEngine assembly during the foreign key creation where certain schema names were not references properly during the foreign key creation.  We fixed it, and I will let you know when a new update is available containing the fix.
By Ozzie Seda, Jr - 10/9/2006

So if I don't have my tables in different schemas within the database, it should create the relationship?

Ozzie

By Trent L. Taylor - 10/9/2006

Yes.  But future updates will not have this issue.
By StrataFrame Team - 10/10/2006

The update posted yesterday will allow you to create relationships between tables in different schemas now Smile