I am struggling to find the markup required to generate the below schema, in particular the unique key on the Description table.
It is a composite key made up of a foreign key and a version number.
I accept that perhaps I should dump the IDENTITY primary key on Description; this still leaves me unsure about how to define a composite key containing a foreign key element however.
Any advice much appreciated.
create table Instrument (
id NUMERIC(19,0) IDENTITY NOT NULL,
primary key (id)
)
create table Description (
id NUMERIC(19,0) IDENTITY NOT NULL,
version NUMERIC(19,0) not null,
instId NUMERIC(19,0) not null,
value VARCHAR(255) null,
primary key (id),
unique (instId, version),
constraint Desc_Inst foreign key (instId) references Instrument
)
|