-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.sql
239 lines (192 loc) · 5.59 KB
/
tables.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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
clear screen;
drop table product cascade constraints;
drop table supplier cascade constraints;
drop table customer cascade constraints;
drop table employee cascade constraints;
drop table log_in_history cascade constraints;
drop table purchase cascade constraints;
drop table product_info cascade constraints;
drop table purchase_history cascade constraints;
drop table temp cascade constraints;
drop table request cascade constraints;
DROP SEQUENCE product_seq;
DROP SEQUENCE supplier_seq;
DROP SEQUENCE customer_seq;
DROP SEQUENCE employee_seq;
DROP SEQUENCE purchase_seq;
DROP SEQUENCE request_seq;
create table product
(
pid NUMBER NOT NULL,
name varchar2(20),
catagory varchar2(20),
brand varchar2(20),
primary key(pid)
);
CREATE SEQUENCE product_seq START WITH 1;
CREATE OR REPLACE TRIGGER product_id
BEFORE INSERT ON product
FOR EACH ROW
BEGIN
SELECT product_seq.NEXTVAL
INTO :new.pid
FROM dual;
END;
/
create table supplier
(
sid NUMBER NOT NULL,
name varchar2(20),
numbers number,
primary key(sid)
);
CREATE SEQUENCE supplier_seq START WITH 1;
CREATE OR REPLACE TRIGGER supplier_id
BEFORE INSERT ON supplier
FOR EACH ROW
BEGIN
SELECT supplier_seq.NEXTVAL
INTO :new.sid
FROM dual;
END;
/
create table customer
(
cid NUMBER NOT NULL,
name varchar2(20),
numbers number,
primary key(cid)
);
CREATE SEQUENCE customer_seq START WITH 1;
CREATE OR REPLACE TRIGGER customer_id
BEFORE INSERT ON customer
FOR EACH ROW
BEGIN
SELECT customer_seq.NEXTVAL
INTO :new.cid
FROM dual;
END;
/
create table employee
(
eid NUMBER NOT NULL,
name varchar2(20),
numbers number,
password varchar2(20),
primary key(eid)
);
CREATE SEQUENCE employee_seq START WITH 1;
CREATE OR REPLACE TRIGGER employee_id
BEFORE INSERT ON employee
FOR EACH ROW
BEGIN
SELECT employee_seq.NEXTVAL
INTO :new.eid
FROM dual;
END;
/
create table log_in_history
(
eid NUMBER,
log_time TIMESTAMP default LOCALTIMESTAMP,
status number
);
create table purchase
(
purchase_id number,
pid number,
product_code number
);
create table product_info
(
product_code number,
pid number,
sid number,
cid number,
buyprice number,
sellprice number,
branch varchar2(20),
condition varchar2(20),
status number
);
create table purchase_history
(
purchase_id NUMBER NOT NULL,
eid number,
cid number,
buyprice number,
soldprice number,
capitalprice number,
purchase_type varchar2(20),
primary key(purchase_id)
);
CREATE SEQUENCE purchase_seq START WITH 1;
CREATE OR REPLACE TRIGGER purch_id
BEFORE INSERT ON purchase_history
FOR EACH ROW
BEGIN
SELECT purchase_seq.NEXTVAL
INTO :new.purchase_id
FROM dual;
END;
/
create table temp
(
pid number,
product_code number,
buyprice number,
sellprice number
);
create table request
(
rid NUMBER NOT NULL,
product_code number,
eid_req number,
send_to_branch varchar2(20),
at_branch varchar2(20),
status number,
eid_done number,
primary key(rid)
);
CREATE SEQUENCE request_seq START WITH 1;
CREATE OR REPLACE TRIGGER request_id
BEFORE INSERT ON request
FOR EACH ROW
BEGIN
SELECT request_seq.NEXTVAL
INTO :new.rid
FROM dual;
END;
/
insert into product(name,catagory,brand) values('Nvidia GTX 1050', 'GPU', 'Gigabyte');
insert into product(name,catagory,brand) values('Nvidia GTX 1060', 'GPU', 'Gigabyte');
insert into product(name,catagory,brand) values('Rx 480', 'GPU', 'AMD');
insert into product(name,catagory,brand) values('RX 460', 'GPU', 'AMD');
insert into product(name,catagory,brand) values('Core i7', 'CPU', 'Intel');
insert into product(name,catagory,brand) values('Core i5', 'CPU', 'Intel');
insert into product(name,catagory,brand) values('Ryzen 5', 'CPU', 'AMD');
insert into product(name,catagory,brand) values('Ryzen 7', 'CPU', 'AMD');
insert into product(name,catagory,brand) values('DDR4 DRAM 2400MHz', 'RAM', 'Corsair');
insert into product(name,catagory,brand) values('DDR4 DRAM 3200MHz', 'RAM', 'Twinmos');
insert into product(name,catagory,brand) values('Litepower 550W', 'PSU', 'Thermaltake');
insert into supplier(name,numbers) values('Global Brand',01768532168);
insert into supplier(name,numbers) values('Ryans',01768532167);
insert into supplier(name,numbers) values('UCCBD',01768532166);
insert into supplier(name,numbers) values('Rishit',01768532165);
insert into customer(name,numbers) values('Himel',01768532171);
insert into customer(name,numbers) values('Nafis',01768532172);
insert into customer(name,numbers) values('Azad',01768532173);
insert into customer(name,numbers) values('Faiza',01768532174);
insert into customer(name,numbers) values('Sefat',01768532175);
insert into employee(name,numbers,password) values('Swapnil',01768532155,'1234');
insert into employee(name,numbers,password) values('Shibli',01768532154,'1234');
insert into employee(name,numbers,password) values('Kumkum',01768532153,'123');
insert into employee(name,numbers,password) values('Jisha',01768532152,'4567');
insert into product_info values(1205,2,2,null,38500,42500,'kalabagan','new',0);
insert into product_info values(1206,2,3,null,38500,42500,'kalabagan','new',0);
insert into product_info values(1207,2,null,2,32000,36000,'Dhanmondi','old',0);
insert into product_info values(1208,3,1,null,45500,48500,'kalabagan','new',0);
insert into product_info values(1209,3,1,null,45500,48500,'Dhanmondi','new',0);
insert into log_in_history (eid,status) values(2,0);
insert into log_in_history (eid,status) values(3,0);
commit;