-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableUsers.sql
28 lines (27 loc) · 1.31 KB
/
TableUsers.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
create table users
(
/*
Users (Users):
UserID (INT, PRIMARY KEY, NOT NULL, UNIQUE)
Username (VARCHAR, NOT NULL)
Password (VARCHAR, NOT NULL)
Email (VARCHAR, NOT NULL, UNIQUE)
Phone (VARCHAR, UNIQUE)
AddressID (INT, FOREIGN KEY REFERENCES Address(AddressID), NOT NULL, UNIQUE) 1:1 with Address
Role (ENUM('admin', 'user'), NOT NULL)
*/
id int auto_increment primary key not null unique,
username varchar(30) not null unique,
password varchar(32) not null,
email varchar(45) not null unique,
phone varchar(15) unique,
address_id int not null unique,
role enum ('admin', 'user') not null,
foreign key (address_id) references addresses(id)
);
INSERT INTO users (username, password, email, phone, address_id, role)
VALUES ('admin', 'admin123', '[email protected]', '123456789', 1, 'admin'),
('user1', 'password1', '[email protected]', '987654321', 2, 'user'),
('user2', 'password2', '[email protected]', NULL, 3, 'user'),
('user3', 'password3', '[email protected]', NULL, 4, 'user'),
('user4', 'password4', '[email protected]', '555555555', 5, 'user');