0

I have a problem..

I need to define foreign keys between federated tables, and I cant do it.. I have two tables...

CREATE TABLE Tarifa(
[cp_id] [int] NOT NULL,
[id] [uniqueidentifier] NOT NULL,
[nombre] [varchar](200) NOT NULL,
[comision] [decimal](18, 2) NULL,
[markUp] [decimal](18, 2) NULL,
PRIMARY KEY (id,cp_id)
) FEDERATED ON (cp_id=cp_id)


CREATE TABLE Periodo(
[cp_id] [int] NOT NULL,
[id] [uniqueidentifier] NOT NULL,
[tarId] [int] NOT NULL,
[precio] [decimal](18, 2) NULL,
PRIMARY KEY (id,cp_id)
) FEDERATED ON (cp_id=cp_id)

I want to reference the field tarId in Periodo to Tarifa. is It possible?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
bombai
  • 927
  • 1
  • 17
  • 27

1 Answers1

0

You can reference federated table with some restrictions.

From the Federation Guideline and Limitations:

All foreign key constraints on federated tables need to include the federation column on both the referrer and the referenced tables at the same ordinal in the foreign key. Reference tables cannot have foreign key relationships with federated tables. Federated tables can have foreign key relationships with reference tables without restrictions.

In your case you have to include the Federated Column on both the tables.

astaykov
  • 30,768
  • 3
  • 70
  • 86