composite One To Many relationship RRS feed

  • Question

  • Hi Guys , 

    i Have 3 Table Project , ProjectStage , ProjectStageActivity 

    Project Can Have Multiple Stages , and Every Stage Can Have Multiple Activity.

    All of The 3 Tables Can Have Multiple Files ,

    the Files Table have SourceID [which may reference ProjectID , Or StageID , Or ActivityID] ,  and SourceType 

    which is int Number [0 for project , 1 for Stage , 2 For Activity]

    How to Build That Relation 

    the problem is when try to insert record to file table with sourceID = 1 [reference project id] for example , i get  error : conflict with foreign key constraint FK_ProjectStageActivity

    any ideas

    omar awwad  

    • Edited by omar_awwad Friday, April 12, 2013 10:27 PM
    Friday, April 12, 2013 10:27 PM

All replies

  • Hi omar,

    I think it is not very clear to tell what is the reason. Since this is a conflict with foreign key constraint FK_ProjectStageActivity, would you like to check whether there is already a record in ProjectStageActivity with "ActivityID" = 1?

    If that doesn't solve the problem, would you like to let us know what's the code you are using to insert the record? Are you using Code First, Model First or Database First?

    Best regards,

    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 16, 2013 8:06 AM