CREATE TABLE Zhanr(
ID_ZHANR INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_ZHANR VARCHAR(20) NOT NULL);

CREATE TABLE Proizvoditel(
ID_PROIZV INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_PROIZV VARCHAR(20) NOT NULL);

CREATE TABLE Vozrast(
ID_VOZR INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
VOZR_OGR VARCHAR(20) NOT NULL);


CREATE TABLE Zal(
ID_ZAL INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_ZAL VARCHAR(20) NOT NULL);

CREATE TABLE Regisser(
ID_REG INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_REG VARCHAR(20) NOT NULL);

CREATE TABLE Producer(
ID_PRODUC INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_PRODUC VARCHAR(20) NOT NULL);

CREATE TABLE Kinokompania(
ID_ KK INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_ KK VARCHAR(20) NOT NULL);

CREATE TABLE GLR(
ID_ GLR INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME_ GLR VARCHAR(20) NOT NULL);


CREATE TABLE Film(
ID_FILM VARCHAR(36) NOT NULL PRIMARY KEY,
NAME_FILM VARCHAR(20) NOT NULL,
FK_ZHANR INT NOT NULL,
FK_PRODUC INT NOT NULL,
FK_PROIZV INT NOT NULL,
FK_VOZR INT NOT NULL,
FK_REG INT NOT NULL,
FK_GLR INT NOT NULL,
FK_KK INT NOT NULL,
GODPRVARCHAR(20) NOT NULL,
FOREIGN KEY(FK_ZHANR) REFERENCES Zhanr (ID_ZHANR)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_PRODUC) REFERENCES Producer (ID_PRODUC)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_PROIZV) REFERENCES Proizvoditel (ID_PROIZV)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_VOZR) REFERENCES Vozrast (ID_VOZR)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_REG) REFERENCES Regisser (ID_REG)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_GLR) REFERENCES GLR (ID_ GLR)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_KK) REFERENCES Kinokompania (ID_ KK)
ON UPDATE NO ACTION
ON DELETE NO ACTION);

CREATE TABLE Afisha(
ID_AFISHA VARCHAR(36) NOT NULL PRIMARY KEY,
FK_FILM INT NOT NULL,
DATA_POKAZ DATATIME NOT NULL,
TIME_POKAZVARCHAR(5) NOT NULL,
FK_ZAL INT NOT NULL,
PRICE INT NOT NULL,
FOREIGN KEY(FK_FILM) REFERENCES Film (ID_FILM)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
FOREIGN KEY(FK_ZAL) REFERENCES Zal(ID_ZAL)
ON UPDATE NO ACTION
ON DELETE NO ACTION); 