0
I’m having a problem intender what the intention of this code below when putting a Constraint to create a primary key for a foreign key.
CREATE TABLE Customer(
IdCustomer integer PRIMARY KEY NOT NULL IDENTITY(1,1),
NmCustomer varchar(255) NOT NULL,
CpfCnpj numeric NOT NULL
);
CREATE TABLE AddressType(
CdAddressType char(1) PRIMARY KEY NOT NULL,
AddressType varchar(50) NOT NULL
);
CREATE TABLE CustomerAddress(
IdCustomer integer,
CdAddressType char(1),
Street varchar(255) NOT NULL,
Lot integer NOT NULL,
Reference varchar(255) NULL,
ZipCode varchar(50) NOT NULL
CONSTRAINT FK_IdCustomer FOREIGN KEY (IdCustomer) REFERENCES Customer(IdCustomer),
CONSTRAINT FK_CdAddressType FOREIGN KEY (CdAddressType) REFERENCES AddressType(CdAddressType),
CONSTRAINT PK_CustomerAddress PRIMARY KEY (IdCustomer, CdAddressType)
);