-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlop.sql
54 lines (46 loc) · 1.49 KB
/
sqlop.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
--Below this line is the sql code for creating tables
--Here will be 5 tables
create table super_user(
sname varchar(30) not null primary key,
realname varchar(30) not null,
w_id varchar(30) not null, --work id
gender varchar(20) not null,
pass_word varchar(40) not null,
age int not null
); --create superuser
create table common_user(
sname varchar(30) not null primary key,
realname varchar(30) not null,
w_id varchar(30) not null, --work id
gender varchar(20) not null,
pass_word varchar(40) not null,
age int not null
); --create commonuser
create table book(
isbn varchar(60) not null primary key,
bookno serial not null, --the number of this book
title varchar(60) not null,
author varchar(60) not null,
publisher varchar(50) not null,
price numeric(7,2) not null,
stock int not null
); --create book
create table bookpurchase
(
purchaseno serial not null primary key,
isbn varchar(60) not null,
title varchar(60) not null,
author varchar(60) not null,
publisher varchar(50) not null,
quantity int not null,
price numeric(7,2) not null,
paidstatus int not null default 0 --0 is unpaid,1 is paid,2 is cancelled
); --create bookpurchase
create table bill
(
billno serial not null primary key,
isbn varchar(30) not null,
catagory varchar(20) not null,
amount numeric(7,2) not null,
time_ timestamp with timezone(0) default current_timestamp(0)
) --create bill