-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsi_exam_data.sql
90 lines (90 loc) · 6.3 KB
/
si_exam_data.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
USE [si_exam]
GO
/****** Object: Table [dbo].[Airport] Script Date: 17/12/2020 14.46.54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Airport](
[name] [nvarchar](256) NOT NULL,
[code] [nchar](3) NOT NULL,
[country] [nvarchar](256) NOT NULL,
CONSTRAINT [PK_Airport] PRIMARY KEY CLUSTERED
(
[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Booking] Script Date: 17/12/2020 14.46.54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Booking](
[id] [int] IDENTITY(1,1) NOT NULL,
[user_id] [int] NOT NULL,
[flight_id] [int] NOT NULL,
[price] [bigint] NOT NULL,
[status] [nvarchar](64) NOT NULL,
[passengers] [int] NOT NULL,
CONSTRAINT [PK_Booking] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Flight] Script Date: 17/12/2020 14.46.54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Flight](
[departure_airport] [nchar](3) NOT NULL,
[arrival_airport] [nchar](3) NOT NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
[image] [nvarchar](512) NOT NULL,
[time] [nchar](5) NOT NULL,
[price] [bigint] NOT NULL,
CONSTRAINT [PK_Flight] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[User] Script Date: 17/12/2020 14.46.54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
[username] [nvarchar](50) NOT NULL,
[name] [nvarchar](128) NOT NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
[password] [nvarchar](50) NOT NULL,
[email] [nvarchar](256) NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Booking] WITH CHECK ADD CONSTRAINT [FK_flight_id] FOREIGN KEY([flight_id])
REFERENCES [dbo].[Flight] ([id])
GO
ALTER TABLE [dbo].[Booking] CHECK CONSTRAINT [FK_flight_id]
GO
ALTER TABLE [dbo].[Booking] WITH CHECK ADD CONSTRAINT [FK_user_id] FOREIGN KEY([user_id])
REFERENCES [dbo].[User] ([id])
GO
ALTER TABLE [dbo].[Booking] CHECK CONSTRAINT [FK_user_id]
GO
ALTER TABLE [dbo].[Flight] WITH CHECK ADD CONSTRAINT [FK_arrival_ariport] FOREIGN KEY([arrival_airport])
REFERENCES [dbo].[Airport] ([code])
GO
ALTER TABLE [dbo].[Flight] CHECK CONSTRAINT [FK_arrival_ariport]
GO
ALTER TABLE [dbo].[Flight] WITH CHECK ADD CONSTRAINT [FK_departure_airport] FOREIGN KEY([departure_airport])
REFERENCES [dbo].[Airport] ([code])
GO
ALTER TABLE [dbo].[Flight] CHECK CONSTRAINT [FK_departure_airport]
GO