-
Notifications
You must be signed in to change notification settings - Fork 0
/
past-underwear-3653.txt
188 lines (147 loc) · 7.63 KB
/
past-underwear-3653.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
C:\ProgramData\MySQL\MySQL Server 8.0\Data\past_underwear_3653
create table Customers (
cuserName varchar(225) NOT NULL PRIMARY KEY,
cpassword varchar(225) NOT NULL,
cname varchar(225) NOT NULL,
address varchar(225) NOT NULL
);
create table CustomerBookedTickets (
cuserName varchar(225),
busNo varchar(225),
bookingTime datetime NOT NULL,
bookedSeat int DEFAULT 0,
FOREIGN KEY (cuserName) REFERENCES Customers(cuserName) on delete cascade on update set null,
FOREIGN KEY (busNo) REFERENCES Buses(busNo) on delete cascade on update set null
)
create table Administrators (
ausername varchar(225) PRIMARY KEY,
apassword varchar(225) NOT NULL,
aname varchar(225) NOT NULL,
address varchar(225) NOT NULL
);
create table Buses (
busNo varchar(10) PRIMARY KEY,
insertBy varchar(225),
date DATE NOT NULL,
source varchar(225) NOT NULL,
sTime DATETIME NOT NULL,
destination varchar(225) NOT NULL,
dTime DATETIME NOT NULL,
type varchar(225) NOT NULL,
bookedSeat int DEFAULT 0,
totalSeat int NOT NULL,
fare int NOT NULL,
FOREIGN KEY (insertBy) REFERENCES Administrators(ausername) on delete cascade on update set null
);
mysql> show tables;
+-------------------------------+
| Tables_in_past_underwear_3653 |
+-------------------------------+
| administrators |
| buses |
| customerbookedtickets |
| customers |
+-------------------------------+
4 rows in set (0.00 sec)
mysql> desc administrators;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| ausername | varchar(225) | NO | PRI | NULL | |
| apassword | varchar(225) | NO | | NULL | |
| aname | varchar(225) | NO | | NULL | |
| address | varchar(225) | NO | | NULL | |
+-----------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc CustomerBookedTickets;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| cuserName | varchar(225) | YES | MUL | NULL | |
| busNo | varchar(225) | YES | MUL | NULL | |
| bookingTime | datetime | NO | | NULL | |
| bookedSeat | int | YES | | 0 | |
+-------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc Customers;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| cuserName | varchar(225) | NO | PRI | NULL | |
| cpassword | varchar(225) | NO | | NULL | |
| cname | varchar(225) | NO | | NULL | |
| address | varchar(225) | NO | | NULL | |
+-----------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc buses;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| busNo | varchar(10) | NO | PRI | NULL | |
| insertBy | varchar(10) | YES | MUL | NULL | |
| date | date | NO | | NULL | |
| source | varchar(225) | NO | | NULL | |
| sTime | datetime | NO | | NULL | |
| destination | varchar(225) | NO | | NULL | |
| dTime | datetime | NO | | NULL | |
| type | varchar(225) | NO | | NULL | |
| bookedSeat | int | YES | | 0 | |
| totalSeat | int | NO | | NULL | |
| fare | int | NO | | NULL | |
+-------------+--------------+------+-----+---------+-------+
11 rows in set (0.00 sec)
insert into customers values('pratik@gmail.com', '123' ,'Pratik Sontakke', 'Amravati (MH)');
insert into customers values('vicky@gmail.com', '123' ,'Vicky Sontakke', 'Amravati (MH)');
insert into customers values('akash@gmail.com', '123' ,'Akash Koli', 'Amravati (MH)');
mysql> select * from customers;
+------------------+-----------+-----------------+---------------+
| cuserName | cpassword | cname | address |
+------------------+-----------+-----------------+---------------+
| akash@gmail.com | 123 | Akash Koli | Amravati (MH) |
| kia@gmail.com | 123 | Kia Kia | LA (USA) |
| pratik@gmail.com | 123 | Pratik Sontakke | Amravati (MH) |
| vicky@gmail.com | 123 | Vicky Sontakke | Amravati (MH) |
+------------------+-----------+-----------------+---------------+
4 rows in set (0.00 sec)
insert into administrators values('pratik123@gmail.com', '123' ,'Pratik Sontakke', 'Amravati (MH)');
insert into administrators values('sahil@gmail.com', '123' ,'Sahil Bobade', 'Pune (MH)');
insert into administrators values('prathamesh@gmail.com', '123' ,'Prathamesh Khedkar', 'Mumbai (MH)');
mysql> select * from administrators;
+----------------------+-----------+--------------------+---------------+
| ausername | apassword | aname | address |
+----------------------+-----------+--------------------+---------------+
| prathamesh@gmail.com | 123 | Prathamesh Khedkar | Mumbai (MH) |
| pratik123@gmail.com | 123 | Pratik Sontakke | Amravati (MH) |
| sahil@gmail.com | 123 | Sahil Bobade | Pune (MH) |
+----------------------+-----------+--------------------+---------------+
3 rows in set (0.01 sec)
//YYYY-MM-DD HH-MM-SS.
insert into buses values(
'MH27BY0001','pratik123@gmail.com', "2022-09-29", 'Amravati',
"2022-09-29 13-40-00",'Manali', "2022-09-30 13-40-00",
'AC', 20, 50, 2500);
insert into buses values(
'MH27BN9001','prathamesh@gmail.com', "2022-09-29", 'Amravati',
"2022-09-29 13-40-00",'Shimla', "2022-09-30 13-40-00",
'AC', 20, 30, 3000);
insert into buses values(
'MH27BZ8701','sahil@gmail.com', "2022-09-29", 'Akola',
"2022-10-05 06-40-00",'Amravati', "2022-10-05 10-20-00",
'Non-AC', 0, 35, 500);
select * from buses;
| busNo | insertBy | date | source | sTime | destination | dTime | type | bookedSeat | totalSeat | fare |
+------------+----------------------+------------+----------+---------------------+-------------+---------------------+------+------------+-----------+------+
| MH27BH8976 | sahil@gmail.com | 2022-10-15 | DELHI | 2022-10-15 14:00:00 | AMRAVATI | 2022-10-18 10:30:00 | AC | 0 | 50 | 8000 |
| MH27BN9001 | prathamesh@gmail.com | 2022-09-29 | Amravati | 2022-09-29 13:40:00 | Shimla | 2022-09-30 13:40:00 | AC | 0 | 30 | 3000 |
+------------+----------------------+------------+----------+---------------------+-------------+---------------------+------+------------+-----------+------+
4 rows in set (0.00 sec)
insert into CustomerBookedTickets values ('pratik@gmail.com', 'MH27BN9001', now(), 20);
insert into CustomerBookedTickets values ('akash@gmail.com', 'MH27BY0001', now(), 20);
mysql> select * from CustomerBookedTickets;
+------------------+------------+---------------------+------------+
| cuserName | busNo | bookingTime | bookedSeat |
+------------------+------------+---------------------+------------+
| pratik@gmail.com | MH27BN9001 | 2022-09-30 18:19:45 | 20 |
| akash@gmail.com | MH27BY0001 | 2022-09-30 18:19:49 | 20 |
+------------------+------------+---------------------+------------+
2 rows in set (0.00 sec)