/* Create Table Bar */
CREATE TABLE Bar(
	id bigint IDENTITY(1, 1) CONSTRAINT nn_Bar_id NOT NULL,
    barValue nvarchar(100)
)

/* Create Table Bar Primary Key */
ALTER TABLE Bar WITH NOCHECK ADD 
	CONSTRAINT PK_Bar PRIMARY KEY CLUSTERED
	(
		id
	)
GO

/* Create Table Foo */
CREATE TABLE Foo(
	id bigint IDENTITY(1, 1) CONSTRAINT nn_Foo_id NOT NULL,
	barId bigint NULL,
    fooValue nvarchar(100)
)

/* Create Table Foo Primary Key */
ALTER TABLE Foo WITH NOCHECK ADD 
	CONSTRAINT PK_Foo PRIMARY KEY CLUSTERED
	(
		id
	)
GO

/* Create Table Foo Foreign Keys */
ALTER TABLE Foo ADD 
	CONSTRAINT fk_Foo_BarId FOREIGN KEY
	(
		barId
	) REFERENCES Bar (
		id
	) ON DELETE CASCADE
GO
