-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice_data.sql
134 lines (114 loc) · 2.11 KB
/
invoice_data.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
CREATEs database invoice;
CREATE TABLE customer (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone_number VARCHAR(255) NOT NULL,
street_address VARCHAR(255) NOT NULL,
city VARCHAR(255) NOT NULL,
contact VARCHAR(255) NOT NULL,
contact_number VARCHAR(15) NOT NULL,
contact_city VARCHAR(255) NOT NULL,
contact_address VARCHAR(255) NOT NULL,
created TIMESTAMP,
modified TIMESTAMP
);
INSERT INTO customer (
name,
email,
phone_number,
street_address,
city,
contact,
contact_number,
contact_city,
contact_address)
VALUES (
'Company One',
'companyone@gmail.com',
'0731051452',
'42 Harley Stureet',
'Johanesburg',
'Hlami',
'0731051452',
'Johanessburg',
'42 Harley Stureet'
);
CREATE TABLE product (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price FLOAT NOT NULL,
is_taxed BOOLEAN DEFAULT FALSE,
created TIMESTAMP
);
INSERT INTO product (
name,
price,
is_taxed)
VALUES (
'Banana',
'10.00',
FALSE
);
INSERT INTO product (
name,
price,
is_taxed)
VALUES (
'Apple',
'15.00',
FALSE
);
INSERT INTO product (
name,
price,
is_taxed)
VALUES (
'Eggs',
'30.00',
True
);
CREATE TABLE invoice (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
customer_id INT UNSIGNED,
created TIMESTAMP,
FOREIGN KEY (customer_id) REFERENCES customer(id)
);
INSERT INTO invoice (
customer_id,
created
)
VALUES (
1,
now()
);
CREATE TABLE invoice_item (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
invoice_id INT UNSIGNED,
product_id INT UNSIGNED,
qty INT NOT NULL,
created TIMESTAMP,
FOREIGN KEY (product_id) REFERENCES product(id)
);
INSERT INTO invoice_item (
invoice_id,
product_id,
qty,
created)
VALUES (
1,
1,
1,
now()
);
INSERT INTO invoice_item (
invoice_id,
product_id,
qty,
created)
VALUES (
1,
2,
2,
now()
);