Repository navigation
Expand file tree
/
Copy pathsetup.sql
More file actions
59 lines (50 loc) · 1.75 KB
/
Copy pathsetup.sql
File metadata and controls
59 lines (50 loc) · 1.75 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
-- SQL script to create the necessary tables for the Smart Split application.
-- To use this file, open phpMyAdmin, select your 'smart_split' database,
-- and import this file.
--
-- Database: `smart_split`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL UNIQUE,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL UNIQUE,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Table structure for table `people`
--
CREATE TABLE `people` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`emoji` varchar(16) NOT NULL,
`userId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
CONSTRAINT `people_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `expenses`
--
CREATE TABLE `expenses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(255) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`payerId` int(11) NOT NULL,
`date` date NOT NULL,
`category` varchar(100) NOT NULL,
`splitBetween` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`splitAmount` decimal(10,2) NOT NULL,
`timestamp` bigint(20) NOT NULL,
`userId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `payerId` (`payerId`),
KEY `userId` (`userId`),
CONSTRAINT `expenses_ibfk_1` FOREIGN KEY (`payerId`) REFERENCES `people` (`id`) ON DELETE RESTRICT,
CONSTRAINT `expenses_ibfk_2` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;