CREATE TABLE [dbo].[ris_risks_situations_main_invoices]
(
[rismi_risk_situation_id] [int] NOT NULL,
[rismi_invoice_id] [int] NOT NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[ris_risks_situations_main_invoices] ADD 
CONSTRAINT [PK_ris_risks_situations_main_invoices_1] PRIMARY KEY CLUSTERED  ([rismi_risk_situation_id], [rismi_invoice_id]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[ris_risks_situations_main_invoices] ADD CONSTRAINT [FK_ris_risks_situations_main_invoices_acc_invoices] FOREIGN KEY ([rismi_invoice_id]) REFERENCES [dbo].[acc_invoices] ([inv_invoice_id])
GO
ALTER TABLE [dbo].[ris_risks_situations_main_invoices] ADD CONSTRAINT [FK_ris_risks_situations_main_invoices_acc_invoices_risks_situations] FOREIGN KEY ([rismi_invoice_id], [rismi_risk_situation_id]) REFERENCES [dbo].[acc_invoices_risks_situations] ([invris_invoice_id], [invris_risk_situation_id])
GO
ALTER TABLE [dbo].[ris_risks_situations_main_invoices] ADD CONSTRAINT [FK_ris_risks_situations_main_invoices_ris_risks_situations] FOREIGN KEY ([rismi_risk_situation_id]) REFERENCES [dbo].[ris_risks_situations] ([riss_risk_situation_id])
GO
