-
Notifications
You must be signed in to change notification settings - Fork 0
/
railway.txt
202 lines (177 loc) · 6.72 KB
/
railway.txt
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
-- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 09, 2020 at 07:57 AM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.2.28
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `railways`
--
CREATE DATABASE IF NOT EXISTS `railways` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `railways`;
-- --------------------------------------------------------
--
-- Table structure for table `schedule`
--
CREATE TABLE `schedule` (
`scode` varchar(4) DEFAULT NULL,
`tarr` varchar(6) DEFAULT NULL,
`tdept` varchar(6) DEFAULT NULL,
`tno` int(11) DEFAULT NULL,
`sname` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `schedule`
--
INSERT INTO `schedule` (`scode`, `tarr`, `tdept`, `tno`, `sname`) VALUES
('sdh', '7.10', '7.15', 121, 'sealdah'),
('dum', '7.30', '7.45', 121, 'dumdum'),
('durg', '8.00', '8.05', 121, 'durganagar'),
('bar', '8.15', '8.25', 121, 'barasat'),
('bon', '8.15', '8.25', 121, 'bonga'),
('sdh', '7.45', '8.00', 122, 'sealdah'),
('dum', '8.15', '8.30', 122, 'dumdum'),
('dan', '9.00', '9.30', 122, 'dunkunki'),
('how', '11.00', '11.30', 123, 'howrah'),
('bard', '13.00', '13.30', 123, 'bardhaman'),
('sdh', '13.00', '13.30', 124, 'sealdah'),
('bid', '13.40', '13.45', 124, 'bidhannagar'),
('dum', '13.50', '13.55', 124, 'dumdum'),
('bark', '14.00', '14.15', 124, 'barrackpore'),
('kal', '14.50', '14.55', 124, 'kalyani'),
('ran', '14.60', '15.55', 124, 'ranaghat'),
('sdh', '14.60', '15.55', 124, 'sealdah'),
('sdh', '14.60', '15.55', 125, 'sealdah'),
('bid', '14.60', '15.55', 125, 'bidhannagar'),
('dum', '14.60', '15.55', 125, 'dumdum'),
('bark', '14.60', '15.55', 125, 'barackpore'),
('kal', '14.60', '15.55', 125, 'kalyani'),
('ran', '14.60', '15.55', 125, 'ranaghat'),
('kri', '14.60', '15.55', 125, 'krishnanagar');
-- --------------------------------------------------------
--
-- Table structure for table `train`
--
CREATE TABLE `train` (
`tno` int(11) NOT NULL,
`tname` varchar(30) DEFAULT NULL,
`tsource` varchar(30) DEFAULT NULL,
`tdestination` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `train`
--
INSERT INTO `train` (`tno`, `tname`, `tsource`, `tdestination`) VALUES
(121, 'bonga local', 'sealdah', 'bonga'),
(122, 'dankuni local', 'sealdah', 'dankuni'),
(123, 'keora local', 'howrah', 'bardhaman'),
(124, 'ranaghat local', 'sealdah', 'ranaghat'),
(125, 'krishnonagar local', 'sealdah', 'krishnonagar');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `schedule`
--
ALTER TABLE `schedule`
ADD KEY `tno` (`tno`);
--
-- Indexes for table `train`
--
ALTER TABLE `train`
ADD PRIMARY KEY (`tno`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `schedule`
--
ALTER TABLE `schedule`
ADD CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`tno`) REFERENCES `train` (`tno`);
COMMIT;
MariaDB [railways]> desc train;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| tno | int(11) | NO | PRI | NULL | |
| tname | varchar(30) | YES | | NULL | |
| tsource | varchar(30) | YES | | NULL | |
| tdestination | varchar(30) | YES | | NULL | |
+--------------+-------------+------+-----+---------+-------+
4 rows in set (0.048 sec)
MariaDB [railways]> desc schedule;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| scode | varchar(4) | YES | | NULL | |
| tarr | varchar(6) | YES | | NULL | |
| tdept | varchar(6) | YES | | NULL | |
| tno | int(11) | YES | MUL | NULL | |
| sname | varchar(30) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
5 rows in set (0.055 sec)
MariaDB [railways]> select * from train;
+-----+--------------------+---------+--------------+
| tno | tname | tsource | tdestination |
+-----+--------------------+---------+--------------+
| 121 | bonga local | sealdah | bonga |
| 122 | dankuni local | sealdah | dankuni |
| 123 | keora local | howrah | bardhaman |
| 124 | ranaghat local | sealdah | ranaghat |
| 125 | krishnonagar local | sealdah | krishnonagar |
+-----+--------------------+---------+--------------+
5 rows in set (0.001 sec)
MariaDB [railways]> select * from schedule;
+-------+-------+-------+------+--------------+
| scode | tarr | tdept | tno | sname |
+-------+-------+-------+------+--------------+
| sdh | 7.10 | 7.15 | 121 | sealdah |
| dum | 7.30 | 7.45 | 121 | dumdum |
| durg | 8.00 | 8.05 | 121 | durganagar |
| bar | 8.15 | 8.25 | 121 | barasat |
| bon | 8.15 | 8.25 | 121 | bonga |
| sdh | 7.45 | 8.00 | 122 | sealdah |
| dum | 8.15 | 8.30 | 122 | dumdum |
| dan | 9.00 | 9.30 | 122 | dunkunki |
| how | 11.00 | 11.30 | 123 | howrah |
| bard | 13.00 | 13.30 | 123 | bardhaman |
| sdh | 13.00 | 13.30 | 124 | sealdah |
| bid | 13.40 | 13.45 | 124 | bidhannagar |
| dum | 13.50 | 13.55 | 124 | dumdum |
| bark | 14.00 | 14.15 | 124 | barrackpore |
| kal | 14.50 | 14.55 | 124 | kalyani |
| ran | 14.60 | 15.55 | 124 | ranaghat |
| sdh | 14.60 | 15.55 | 124 | sealdah |
| sdh | 14.60 | 15.55 | 125 | sealdah |
| bid | 14.60 | 15.55 | 125 | bidhannagar |
| dum | 14.60 | 15.55 | 125 | dumdum |
| bark | 14.60 | 15.55 | 125 | barackpore |
| kal | 14.60 | 15.55 | 125 | kalyani |
| ran | 14.60 | 15.55 | 125 | ranaghat |
| kri | 14.60 | 15.55 | 125 | krishnanagar |
+-------+-------+-------+------+--------------+
24 rows in set (0.001 sec)
MariaDB [railways]> select tname,tsource,tdestination
-> from train
-> where tno in(
-> select distinct(t.tno)
-> from schedule t,schedule s
-> where t.tno=s.tno
-> and
-> t.sname="sealdah"
-> and
-> s.sname="kalyani"
-> );
+--------------------+---------+--------------+
| tname | tsource | tdestination |
+--------------------+---------+--------------+
| ranaghat local | sealdah | ranaghat |
| krishnonagar local | sealdah | krishnonagar |
+--------------------+---------+--------------+
2 rows in set (0.001 sec)