-
Notifications
You must be signed in to change notification settings - Fork 0
/
testtesttest.sql
103 lines (76 loc) · 1.96 KB
/
testtesttest.sql
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
CREATE TABLE Áèëåòû
(
Íîìåð_áèëåòà integer NOT NULL ,
Òèï_áèëåòà varchar(20) NULL ,
Íîìåð_ìåñòà integer NULL ,
Íîìåð_ïàññàæèðà integer NULL ,
Íîìåð_ðåéñà integer NULL
)
go
ALTER TABLE Áèëåòû
ADD CONSTRAINT XPKÁèëåòû PRIMARY KEY CLUSTERED (Íîìåð_áèëåòà ASC)
go
CREATE TABLE Ïàññàæèðû
(
Èìÿ varchar(20) NULL ,
Ôàìèëèÿ varchar(20) NULL ,
Îò÷åñòâî varchar(20) NULL ,
Äàòà_Ðîæäåíèÿ datetime NULL ,
Ïîë varchar(20) NULL ,
Ñåðèÿ_ïàñïîðòà integer NULL ,
Íîìåð_ïàñïîðòà integer NULL ,
Íîìåð_ïàññàæèðà integer NOT NULL
)
go
ALTER TABLE Ïàññàæèðû
ADD CONSTRAINT XPKÏàññàæèðû PRIMARY KEY CLUSTERED (Íîìåð_ïàññàæèðà ASC)
go
CREATE TABLE Ïîëüçîâàòåëè
(
Ëîãèí varchar(20) NOT NULL ,
Ïàðîëü varbinary() NULL
)
go
ALTER TABLE Ïîëüçîâàòåëè
ADD CONSTRAINT XPKÏîëüçîâàòåëè PRIMARY KEY CLUSTERED (Ëîãèí ASC)
go
CREATE TABLE Ðåéñû
(
Íîìåð_ðåéñà integer NOT NULL ,
Äàòà_âûëåòà datetime NULL ,
Äàòà_ïðèëåòà datetime NULL ,
Ïóíêò_îòïðàâëåíèÿ varchar(20) NULL ,
Ïóíêò_íàçíà÷åíèÿ varchar(20) NULL ,
Íîìåð_ñàìîëåòà integer NULL ,
Âðåìÿ_âûëåòà datetime NULL ,
Âðåìÿ_ïðèëåòà datetime NULL
)
go
ALTER TABLE Ðåéñû
ADD CONSTRAINT XPKÐåéñû PRIMARY KEY CLUSTERED (Íîìåð_ðåéñà ASC)
go
CREATE TABLE Ñàìîëåòû
(
Íîìåð_ñàìîëåòà integer NOT NULL ,
Òèï_ñàìîëåòà varchar(20) NULL ,
Êîë_âî_ìåñò integer NULL
)
go
ALTER TABLE Ñàìîëåòû
ADD CONSTRAINT XPKÑàìîëåòû PRIMARY KEY CLUSTERED (Íîìåð_ñàìîëåòà ASC)
go
ALTER TABLE Áèëåòû
ADD CONSTRAINT R_4 FOREIGN KEY (Íîìåð_ïàññàæèðà) REFERENCES Ïàññàæèðû(Íîìåð_ïàññàæèðà)
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE Áèëåòû
ADD CONSTRAINT R_6 FOREIGN KEY (Íîìåð_ðåéñà) REFERENCES Ðåéñû(Íîìåð_ðåéñà)
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE Ðåéñû
ADD CONSTRAINT R_1 FOREIGN KEY (Íîìåð_ñàìîëåòà) REFERENCES Ñàìîëåòû(Íîìåð_ñàìîëåòà)
ON DELETE NO ACTION
ON UPDATE NO ACTION
go