Comments
Sort by recent activity
Assuming the following table structure, the FK you would need is in the last lines of code. Is this what you need?
CREATE TABLE Product ( ProductCode VARCHAR(30) PRIMARY KEY
, ProductDesc VARCHAR(100));
CREATE TABLE SubProduct ( SubProductCode VARCHAR(30) PRIMARY KEY
, ProductCode VARCHAR(30)
, SubProductDesc VARCHAR(100));
ALTER TABLE dbo.SubProduct
ADD CONSTRAINT fk_SubProduct_ProductCode
FOREIGN KEY( ProductCode )
REFERENCES dbo.Product( ProductCode );
CREATE TABLE ForSale ( SaleCode VARCHAR(30)
, ProductCode VARCHAR(30)
, SubProductCode VARCHAR(30)
, SaleDesc VARCHAR(100));
ALTER TABLE dbo.SubProduct
ADD CONSTRAINT fk_ForSale_ProductCode
FOREIGN KEY( ProductCode )
REFERENCES dbo.Product( ProductCode );
ALTER TABLE ForSale
ADD CONSTRAINT fk_ForSale_SubProductCode_within_ProductCode
FOREIGN KEY( ProductCode, SubProductCode )
REFERENCES dbo.SubProduct( ProductCode, SubProductCode ); / comments
Assuming the following table structure, the FK you would need is in the last lines of code. Is this what you need?
CREATE TABLE Product ( ProductCode VARCHAR(30) PRIMARY KEY
, ProductDesc VARCHA...