-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemandi_onto.sql
92 lines (80 loc) · 2.31 KB
/
emandi_onto.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
create table ADMIN(
admin_name VARCHAR(50) PRIMARY KEY,
password VARCHAR(150) NOT NULL
);
create table STATE(
state_id TINYINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(25) UNIQUE NOT NULL
);
create table CITY(
city_id SMALLINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(25) NOT NULL,
state_id TINYINT NOT NULL,
UNIQUE(state_id, name),
FOREIGN KEY (state_id)
REFERENCES STATE(state_id)
ON DELETE CASCADE
);
create table VENDOR (
vendor_id INT AUTO_INCREMENT PRIMARY KEY,
contact BIGINT UNIQUE NOT NULL,
type VARCHAR(25),
name VARCHAR(25),
state_id TINYINT,
city_id SMALLINT,
pin_code INT,
address VARCHAR(1000),
profile_picture VARCHAR(1000),
reg_timestamp TIMESTAMP NOT NULL DEFAULT NOW(),
device_fcm_token VARCHAR(500),
orders_recieved INT DEFAULT 0,
orders_cancelled_by_user INT DEFAULT 0,
orders_cancelled_by_vendor INT DEFAULT 0,
order_domino_number TINYINT DEFAULT 0,
defaulter_status VARCHAR(30) DEFAULT "NO_ISSUE",
defaulter_timestamp TIMESTAMP DEFAULT "1999-01-01 00:00:00",
defaulter_period TIMESTAMP DEFAULT "1999-01-01 00:00:00",
FOREIGN KEY (state_id)
REFERENCES STATE(state_id)
ON DELETE CASCADE,
FOREIGN KEY (city_id)
REFERENCES CITY(city_id)
ON DELETE CASCADE
);
create table USER(
user_id INT PRIMARY KEY AUTO_INCREMENT,
device_fcm_token VARCHAR(500),
contact BIGINT UNIQUE NOT NULL,
name VARCHAR(25),
state_id TINYINT,
city_id SMALLINT,
pin_code INT,
reg_timestamp TIMESTAMP NOT NULL DEFAULT NOW(),
address VARCHAR(1000),
profile_picture VARCHAR(1000),
orders_issued INT DEFAULT 0,
orders_cancelled_by_user INT DEFAULT 0,
order_domino_number TINYINT DEFAULT 0,
defaulter_status VARCHAR(30) DEFAULT "NO_ISSUE",
defaulter_timestamp TIMESTAMP DEFAULT "1999-01-01 00:00:00",
defaulter_period TIMESTAMP DEFAULT "1999-01-01 00:00:00",
FOREIGN KEY (state_id)
REFERENCES STATE(state_id)
ON DELETE CASCADE,
FOREIGN KEY (city_id)
REFERENCES CITY(city_id)
ON DELETE CASCADE
);
create table OTP_SIGNUP(
subscriber_type VARCHAR(20) NOT NULL,
contact BIGINT NOT NULL,
otp INT NOT NULL,
reg_timestamp TIMESTAMP DEFAULT NOW()
);
create table OTP_LOGIN(
subscriber_id INT NOT NULL,
subscriber_type VARCHAR(20) NOT NULL,
contact BIGINT NOT NULL,
otp INT NOT NULL,
reg_timestamp TIMESTAMP DEFAULT NOW()
);