How to define Relationship between 3 tables of unique records

  • My Scenario is this:-

    4 Tables t1-t4, t1-t3 each have unique records that when entered into 3 fields in t4 produce a combined unique record.

    t1

    Field1(PK)

    t2

    Field1(PK)

    t3

    Field1(PK)

    t4

    t4.Field1=t1.Field1

    t4.Field2=t2.Field1

    t4.Field3=t3.Field1

    The result of this is that t4.Field1,2,3 together is a unique record in t4

    My problem is how to setup the relationships from t1,t2,t3 to t4 so that any insert update or delete in t1, t2, or t3 is reflected in t4

    sorry i'm a novice and probably haven't got the terminology correct for that I apologize.

  • you could use triggers to insert the data into T4 when it is inseted into T1 - T3

    but a better idea would be to have T4 as a view then it would always be up to date with whats in T1-T3, as it does not make sense from your example to physically repeat the data in another table.

  • ironoverload (2/2/2011)


    My Scenario is this:-

    4 Tables t1-t4, t1-t3 each have unique records that when entered into 3 fields in t4 produce a combined unique record.

    t1

    Field1(PK)

    t2

    Field1(PK)

    t3

    Field1(PK)

    t4

    t4.Field1=t1.Field1

    t4.Field2=t2.Field1

    t4.Field3=t3.Field1

    The result of this is that t4.Field1,2,3 together is a unique record in t4

    My problem is how to setup the relationships from t1,t2,t3 to t4 so that any insert update or delete in t1, t2, or t3 is reflected in t4

    I think the description of the scenario lacks needed details.

    1- Does T4 holds rows that represent all T1+T2+T3 combinations?

    2- If not... how can you tell which T1+T2+T3 combinations are allowed and which ones are not?

    3- How T1,T2,T3 get inserted/deleted/updated? does it happens in sync?

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply