-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatements.sql
More file actions
48 lines (42 loc) · 3.5 KB
/
statements.sql
File metadata and controls
48 lines (42 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ALTER TABLE LTexts DROP CONSTRAINT IF EXISTS FKLTexts616762;
ALTER TABLE LTexts DROP CONSTRAINT IF EXISTS FKLTexts180567;
ALTER TABLE Printery DROP CONSTRAINT IF EXISTS FKPrintery392784;
ALTER TABLE Printery DROP CONSTRAINT IF EXISTS FKPrintery136434;
ALTER TABLE EuropeSeries DROP CONSTRAINT IF EXISTS FKEuropeSeri285393;
ALTER TABLE OldSeries DROP CONSTRAINT IF EXISTS FKOldSeries683952;
ALTER TABLE EuropeSeries DROP CONSTRAINT IF EXISTS FKEuropeSeri541743;
ALTER TABLE LCities DROP CONSTRAINT IF EXISTS FKLCities418157;
ALTER TABLE LCities DROP CONSTRAINT IF EXISTS FKLCities35967;
ALTER TABLE LCountries DROP CONSTRAINT IF EXISTS FKLCountries422765;
ALTER TABLE LCountries DROP CONSTRAINT IF EXISTS FKLCountries775008;
DROP TABLE IF EXISTS OldSeries;
DROP TABLE IF EXISTS Printery;
DROP TABLE IF EXISTS Texts;
DROP TABLE IF EXISTS LCities;
DROP TABLE IF EXISTS LCountries;
DROP TABLE IF EXISTS LTexts;
DROP TABLE IF EXISTS Cities;
DROP TABLE IF EXISTS Countries;
DROP TABLE IF EXISTS EuropeSeries;
DROP TABLE IF EXISTS Language;
CREATE TABLE Cities (id int IDENTITY NOT NULL, code char(6) NOT NULL UNIQUE, PRIMARY KEY (id));
CREATE TABLE Countries (id int IDENTITY NOT NULL, code char(3) NOT NULL UNIQUE, PRIMARY KEY (id));
CREATE TABLE EuropeSeries (id int IDENTITY NOT NULL, code char(1) NOT NULL, printery varchar(255) NOT NULL, countryID int NOT NULL, cityID int NOT NULL, circulation int NOT NULL, PRIMARY KEY (id));
CREATE TABLE Language (languageID int IDENTITY NOT NULL, code char(3) NOT NULL UNIQUE, name varchar(255) NOT NULL UNIQUE, PRIMARY KEY (languageID));
CREATE TABLE LCities (cityID int NOT NULL, languageID int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY (cityID, languageID));
CREATE TABLE LCountries (countryID int NOT NULL, languageID int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY (countryID, languageID));
CREATE TABLE LTexts (textID int NOT NULL, languageID int NOT NULL, text varchar(255) NOT NULL UNIQUE, PRIMARY KEY (textID, languageID));
CREATE TABLE OldSeries (id int IDENTITY NOT NULL, code char(1) NOT NULL, countryID int NOT NULL, circulation bit NOT NULL, PRIMARY KEY (id));
CREATE TABLE Printery (id int IDENTITY NOT NULL, code char(1) NOT NULL, name varchar(255) NOT NULL, countryID int NOT NULL, cityID int NOT NULL, circulation int NOT NULL, PRIMARY KEY (id));
CREATE TABLE Texts (textID int IDENTITY NOT NULL, [desc] varchar(255) NOT NULL UNIQUE, PRIMARY KEY (textID));
ALTER TABLE LTexts ADD CONSTRAINT FKLTexts616762 FOREIGN KEY (languageID) REFERENCES Language (languageID);
ALTER TABLE LTexts ADD CONSTRAINT FKLTexts180567 FOREIGN KEY (textID) REFERENCES Texts (textID);
ALTER TABLE Printery ADD CONSTRAINT FKPrintery392784 FOREIGN KEY (countryID) REFERENCES Countries (id);
ALTER TABLE Printery ADD CONSTRAINT FKPrintery136434 FOREIGN KEY (cityID) REFERENCES Cities (id);
ALTER TABLE EuropeSeries ADD CONSTRAINT FKEuropeSeri285393 FOREIGN KEY (countryID) REFERENCES Countries (id);
ALTER TABLE OldSeries ADD CONSTRAINT FKOldSeries683952 FOREIGN KEY (countryID) REFERENCES Countries (id);
ALTER TABLE EuropeSeries ADD CONSTRAINT FKEuropeSeri541743 FOREIGN KEY (cityID) REFERENCES Cities (id);
ALTER TABLE LCities ADD CONSTRAINT FKLCities418157 FOREIGN KEY (languageID) REFERENCES Language (languageID);
ALTER TABLE LCities ADD CONSTRAINT FKLCities35967 FOREIGN KEY (cityID) REFERENCES Cities (id);
ALTER TABLE LCountries ADD CONSTRAINT FKLCountries422765 FOREIGN KEY (languageID) REFERENCES Language (languageID);
ALTER TABLE LCountries ADD CONSTRAINT FKLCountries775008 FOREIGN KEY (countryID) REFERENCES Countries (id);