CREATE TABLE dbo.B_DIAG
	(
	ID_B_DIAG int NOT NULL IDENTITY (1, 1),
	ID_SLUCH int NULL,
	DIAG_TIP numeric(1, 0) NULL,
	DIAG_CODE numeric(3, 0) NULL,
	DIAG_RSLT numeric(3, 0) NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.B_DIAG ADD CONSTRAINT
	PK_B_DIAG_1 PRIMARY KEY CLUSTERED 
	(
	ID_B_DIAG
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
ALTER TABLE dbo.B_DIAG ADD CONSTRAINT
	FK_B_DIAG_Sluch FOREIGN KEY
	(
	ID_SLUCH
	) REFERENCES dbo.Sluch
	(
	ID_SLUCH
	) ON UPDATE  NO ACTION 
	 ON DELETE  CASCADE 
GO

CREATE TABLE dbo.B_PROT
	(
	ID_B_PROT int NOT NULL IDENTITY (1, 1),
	ID_SLUCH int NULL,
	PROT numeric(1, 0) NULL,
	D_PROT datetime NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.B_PROT ADD CONSTRAINT
	PK_B_PROT_1 PRIMARY KEY CLUSTERED 
	(
	ID_B_PROT
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
ALTER TABLE dbo.B_PROT ADD CONSTRAINT
	FK_B_PROT_Sluch FOREIGN KEY
	(
	ID_SLUCH
	) REFERENCES dbo.Sluch
	(
	ID_SLUCH
	) ON UPDATE  NO ACTION 
	 ON DELETE  CASCADE 
GO

CREATE TABLE dbo.NAPR
	(
	ID_NAPR int NOT NULL IDENTITY (1, 1),
	ID_USL int NULL,
	NAPR_DATE datetime NULL,
	MET_V numeric(1, 0) NULL,
	MET_ISSL numeric(1, 0) NULL,
	NAPR_USL varchar(15) NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.NAPR ADD CONSTRAINT
	PK_NAPR_1 PRIMARY KEY CLUSTERED 
	(
	ID_NAPR
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
ALTER TABLE dbo.NAPR ADD CONSTRAINT
	FK_NAPR_Usk FOREIGN KEY
	(
	ID_USL
	) REFERENCES dbo.Usl
	(
	ID_USL
	) ON UPDATE  NO ACTION 
	 ON DELETE  CASCADE 
GO