4
I wonder how to create a composite primary key in a weak relationship.
I mean, I create the two relationship tables and I don’t know how to "pull" the primary key to the weak table. I must pull it as foreign key before and only then create composite key?
That would be it, for example?
Create Table TabelaForte(
Idforte Integer Identify(1,1) not null,
Nome Varchar(50) not null,
Descrição Varchar(50) not null,
)
Create Table TabelaFraca(
Idfraco Integer Identify(1,1) not null,
Atributo1 Varchar(50) not null,
Atributo2 Varchar(50) not null,
)
ALTER TABLE TabelaForte
ADD (PRIMARY KEY (Idforte));
ALTER TABLE TabelaFraca
ADD (FOREIGN KEY(Idforte) REFERENCES TabelaForte);
ALTER TABLE TabelaFraca
ADD CONSTRAINT chave_composta PRIMARY KEY CLUSTERED (Idforte, Idfraco)
You are using which database?
– Paulo Roberto