locked
Constraint errors for foreign key tables RRS feed

  • Question

  • Hi,

    I have a failty simplistic subset of tables, namely

    Assessment

    AsessmentOrder

    Obviously assessementorder is a foreign key table having a foreigh key AssessmentID. We have implemented a ipad ap based on the sample provided with the toolkit and the issue we have is that when we add an assessment and assessmentorder table/s and then sync, it adds the assessment table ok, but we get a foreign key constraing error for the other information.

    I assume this is because the service tries to write all the information in one SQL statement, so when rows that aren't from the Assessments table offer up their AssessmentID foreign keys, there is no Assessment row to match them to?

    What I want to know is how do we somehow let the sync context model know of these relationships so it can deal with accordingly, do I need to specify the order somehow, or decaorate the entity context model with attributes, so that the sync service will take care of this, and do things in teh right order.

    I don't know if changes are able to be made to the sync service setup, that will rectify this issue but if not, then we're going to have to start writing code that will upload one thing, check it worked ok then upload the next and so on which would be quite cumbersome, and surely there must be a way round this?

    Monday, May 21, 2012 2:58 PM

Answers

  • how did you add the tables in the scope? normally, you would add the parent table first before the child table...
    • Marked as answer by xcfrt Tuesday, May 22, 2012 10:59 AM
    Monday, May 21, 2012 3:12 PM

All replies

  • how did you add the tables in the scope? normally, you would add the parent table first before the child table...
    • Marked as answer by xcfrt Tuesday, May 22, 2012 10:59 AM
    Monday, May 21, 2012 3:12 PM
  • Hi June,

    Yeh I have noticed parent tables are not added in that order, and so am doing a test by modifying xml blob in scope_config.config_data to test that this works, which looking also at other related posts cetainly seems to be the case.

    Am just finalising unit test and will update this post in morning:-)

    Monday, May 21, 2012 4:56 PM
  • yes great that does indeed work thanks
    Tuesday, May 22, 2012 10:59 AM
  • HI

    How exactly did you change the order of the tables. I am facing the same problem.

    But, the I am adding parent table before the child table in the scope.

    I did not understand the 'xml blob' part that you tried.

    Could you please explain?

    Wednesday, October 17, 2012 12:45 PM
  • HI

    How exactly did you change the order of the tables. I am facing the same problem.

    But, the I am adding parent table before the child table in the scope.

    I did not understand the 'xml blob' part that you tried.

    Could you please explain?

    Wednesday, October 17, 2012 12:46 PM
  • sure if you look in scope_config.config_data , you will see all the tables listed in big xml blob, so in here simply change the order of the tables, thus making sure the parent table is listed first
    Wednesday, October 17, 2012 1:54 PM