-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sql
39 lines (35 loc) · 807 Bytes
/
init.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
CREATE TABLE store(
sid SERIAL PRIMARY KEY,
sname TEXT NOT NULL,
saddress TEXT,
sgstid TEXT
);
CREATE TABLE customer(
cid SERIAL PRIMARY KEY,
cname TEXT NOT NULL,
caddress TEXT,
cgstid TEXT
);
CREATE TABLE product(
pid SERIAL PRIMARY KEY,
name TEXT NOT NULL,
mrp FLOAT NOT NULL,
price FLOAT NOT NULL,
gst INT NOT NULL,
active BOOLEAN DEFAULT TRUE
);
CREATE TABLE invoice(
iid SERIAL PRIMARY KEY,
dt TIMESTAMP NOT NULL,
storeid INT NOT NULL REFERENCES store(sid),
customerid INT REFERENCES customer(cid),
igst BOOLEAN DEFAULT FALSE
);
CREATE TABLE invoiceproduct(
ipid SERIAL PRIMARY KEY,
invoiceid INT NOT NULL REFERENCES invoice(iid),
productid INT NOT NULL REFERENCES product(pid),
price FLOAT NOT NULL,
quantity INT NOT NULL,
usedgst INT NOT NULL
);