none
How to setup replication if no PK? RRS feed

  • Question

  • Hello All,

     

    If the table structure is like this..

    Master and Detail. In Master table has primary key but in the Detail table it is foreign keyed to master table. Basically detail table doesnt have PK. In this situatuion how do we handle replication?
    Sunday, October 26, 2008 2:56 PM

All replies

  • You could use snapshot replicaiton, but if this is a large OLTP app, the snapshots could get huge.

     

    Why doesn't the detail table have a primary key?  Usually, if it is a child table to the Master table, there will be either a surrogate key to uniquely identify the rows (ex. an IDENTITY Column called DetailKey, or something of the sort), or a composite primary key, usually including the foreign key and a row number.  For a given master record, you may have ten lines, and those lines would be numbered 1 through 10.  The primary key would be created on (MasterKey, LineNumber).  The surrogate key is a much better idea though, in my opinion.

     

    Without a primary key, how to you efficiently reference a row for updates and deletes?

    Sunday, October 26, 2008 4:01 PM
    Moderator