-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
47 lines (40 loc) · 1.1 KB
/
database.sql
File metadata and controls
47 lines (40 loc) · 1.1 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
CREATE
DATABASE go_restful_api;
USE
go_restful_api;
CREATE TABLE users
(
username VARCHAR(100) NOT NULL,
password VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
token VARCHAR(100),
token_expired_at BIGINT,
PRIMARY KEY (username),
UNIQUE (token)
) ENGINE = InnoDb;
DESC users;
CREATE TABLE contacts
(
id VARCHAR(100) NOT NULL,
username VARCHAR(100) NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100),
phone VARCHAR(100),
email VARCHAR(100),
PRIMARY KEY (id),
CONSTRAINT fk_users_contacts FOREIGN KEY (username) REFERENCES users (username)
) ENGINE = InnoDb;
DESC contacts;
CREATE TABLE addresses
(
id VARCHAR(100) NOT NULL,
contact_id VARCHAR(100) NOT NULL,
street VARCHAR(200),
city VARCHAR(100),
province VARCHAR(100),
country VARCHAR(100) NOT NULL,
postal_code VARCHAR(10),
PRIMARY KEY (id),
CONSTRAINT fk_contacts_addresses FOREIGN KEY (contact_id) REFERENCES contacts (id)
)ENGINE = InnoDb;
DESC addresses;