-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
100 lines (88 loc) · 3.28 KB
/
Copy pathdatabase.sql
File metadata and controls
100 lines (88 loc) · 3.28 KB
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
DROP TABLE IF EXISTS `users`, `incomes_category_default`, `incomes_category_assigned_to_users`, `incomes`, `expenses_category_default`, `expenses_category_assigned_to_users`, `payment_methods_default`, `payment_methods_assigned_to_users`, `expenses`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`email`)
);
CREATE TABLE IF NOT EXISTS `incomes_category_default` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `incomes_category_default` (`id`, `name`) VALUES
(1, 'salary'),
(2, 'bank interest'),
(3, 'allegro sale'),
(4, 'other');
CREATE TABLE IF NOT EXISTS `incomes_category_assigned_to_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `incomes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`income_category_assigned_to_user_id` int(11) NOT NULL,
`amount` decimal(8,2) NOT NULL,
`date_of_income` date NOT NULL,
`income_comment` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `expenses_category_default` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `expenses_category_default` (`id`, `name`) VALUES
(1, 'food'),
(2, 'house'),
(3, 'transport'),
(4, 'telecom'),
(5, 'health care'),
(6, 'clothing'),
(7, 'hygiene'),
(8, 'children'),
(9, 'entertainment'),
(10, 'trip'),
(11, 'training courses'),
(12, 'books'),
(13, 'debt repayment'),
(14, 'pension'),
(15, 'donation'),
(16, 'other expenses');
CREATE TABLE IF NOT EXISTS `expenses_category_assigned_to_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`category_limit` decimal(8,2) DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `payment_methods_default` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `payment_methods_default` (`id`, `name`) VALUES
(1, 'cash'),
(2, 'credit card'),
(3, 'debit card');
CREATE TABLE IF NOT EXISTS `payment_methods_assigned_to_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `expenses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`expense_category_assigned_to_user_id` int(11) NOT NULL,
`payment_method_assigned_to_user_id` int(11) NOT NULL,
`amount` decimal(8,2) NOT NULL,
`date_of_expense` date NOT NULL,
`expense_comment` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`)
);