You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
749 B

CREATE DATABASE [CompaniesDB];
GO
USE [CompaniesDB];
GO
CREATE TABLE [Company] (
[CompanyId] int NOT NULL IDENTITY,
[Name] nvarchar(max) NOT NULL,
[ContractStatus] int NOT NULL CHECK ([ContractStatus] IN(0, 1, 2)),
CONSTRAINT [PK_CompanyId] PRIMARY KEY ([CompanyId])
);
GO
CREATE TABLE [Users] (
[UserId] int NOT NULL IDENTITY,
[CompanyID] int NOT NULL,
[Name] nvarchar(max) NOT NULL,
[Login] nvarchar(max) NOT NULL,
[Password] nvarchar(max) NOT NULL,
CONSTRAINT [PK_UserId] PRIMARY KEY ([UserId]),
CONSTRAINT [FK_Users_Company] FOREIGN KEY (CompanyID) REFERENCES [Company] (CompanyId) ON DELETE CASCADE
);
GO
INSERT INTO [Company] (Name, ContractStatus) VALUES
('Defend Studio', '0'),
('Yandex Music', '1')
GO