-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdatabase.sql
More file actions
78 lines (76 loc) · 2.94 KB
/
database.sql
File metadata and controls
78 lines (76 loc) · 2.94 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
CREATE DATABASE mxhacks;
DROP TABLE User;
CREATE TABLE User
(
id_user int NOT NULL AUTO_INCREMENT ,
first_name varchar(255) NOT NULL ,
last_name varchar(255) NOT NULL ,
address varchar(255),
credit_candidate int NOT NULL DEFAULT 0 ,
monthly_earnings int NOT NULL DEFAULT 0 ,
current_savings int NOT NULL DEFAULT 0,
has_partner int NOT NULL DEFAULT 0 ,
PRIMARY KEY (id_user)
);
INSERT INTO User(first_name, last_name, address, credit_candidate, current_savings, monthly_earnings) VALUES ("Emilio", "Flores", "Monterrey", 1, 0, 10000);
INSERT INTO User(first_name, last_name, address, credit_candidate, current_savings, monthly_earnings) VALUES ("Enrique", "Hernandez", "Chihuahua", 0, 0, 10000);
DROP TABLE Transaction;
CREATE TABLE Transaction
(
id_trans int NOT NULL AUTO_INCREMENT ,
id_user int NOT NULL ,
type int NOT NULL ,
amount int NOT NULL ,
monthly int NOT NULL ,
created date NOT NULL ,
is_active int NOT NULL DEFAULT 1,
PRIMARY KEY (id_trans)
);
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 666, 0, '2015/10/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 420, 0, '2015-10-03');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 800, 0, '2015/11/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 200, 0, '2015-12-03');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 3000, 1, '2015/10/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 1, 4000, 1, '2015/10/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 2, 540, 0, '2015/10/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 2, 40, 0, '2015-10-03');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 2, 800, 0, '2015/11/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (1, 2, 4000, 1, '2015/10/06');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (2, 1, 420, 200, '2015-10-03');
INSERT INTO Transaction(id_user, type, amount, monthly, created) VALUES (2, 1, 420, 200, '2015-10-03');
DROP TABLE Product;
CREATE TABLE Product
(
id_product int NOT NULL AUTO_INCREMENT ,
id_user int NOT NULL ,
name varchar(255) NOT NULL ,
description varchar(255) ,
amount int NOT NULL ,
completed boolean NOT NULL DEFAULT 0 ,
id_trans int ,
PRIMARY KEY (id_product)
);
DROP TABLE Tanda;
CREATE TABLE Tanda
(
id_tanda int NOT NULL AUTO_INCREMENT ,
id_user int NOT NULL ,
turno int NOT NULL,
name varchar(255) NOT NULL,
intervalo_dias int NOT NULL,
num_personas int NOT NULL,
num_repeticiones int NOT NULL,
cantidad int NOT NULL,
is_active int NOT NULL,
fecha_inicial DATE NOT NULL,
PRIMARY KEY (id_tanda)
);
DROP TABLE UsuariosTanda;
CREATE TABLE UsuariosTanda
(
id_usuarios_tanda int NOT NULL AUTO_INCREMENT,
id_tanda int NOT NULL,
nombre varchar(255) NOT NULL,
turno int NOT NULL,
PRIMARY KEY (id_usuarios_tanda)
);