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
757 B
29 lines
757 B
CREATE DATABASE [CompaniesDB];
|
|
GO
|
|
|
|
USE [CompaniesDB];
|
|
GO
|
|
|
|
CREATE TABLE [Companies] (
|
|
[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_Companies] FOREIGN KEY (CompanyID) REFERENCES [Companies] (CompanyId) ON DELETE CASCADE
|
|
);
|
|
GO
|
|
|
|
INSERT INTO [Companies] (Name, ContractStatus) VALUES
|
|
('Defend Studio', '0'),
|
|
('Yandex Music', '1')
|
|
GO
|