-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathModelo banco.txt
More file actions
38 lines (32 loc) · 1.19 KB
/
Modelo banco.txt
File metadata and controls
38 lines (32 loc) · 1.19 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
CREATE TABLE roles (
role_id INT PRIMARY KEY,
role_name VARCHAR(50)
);
INSERT INTO roles (role_id, role_name) VALUES (1, 'user');
INSERT INTO roles (role_id, role_name) VALUES (2, 'administrator');
CREATE TABLE users (
id_user SERIAL PRIMARY KEY,
role_id INT,
name_user VARCHAR (30),
email VARCHAR (30) UNIQUE,
password_user VARCHAR (30),
perfil VARCHAR (30),
cpf_user NUMERIC (11) UNIQUE,
status_user VARCHAR (30),
createdat VARCHAR (30),
updatedat VARCHAR (30),
FOREIGN KEY (role_id) REFERENCES roles(role_id)
);
CREATE TABLE permissions (
permission_id SERIAL PRIMARY KEY,
role_id INT,
resource_name VARCHAR(50),
can_view BOOLEAN,
can_edit_email BOOLEAN,
can_edit_password BOOLEAN,
can_edit_cpf BOOLEAN,
can_edit_status BOOLEAN,
FOREIGN KEY (role_id) REFERENCES roles(role_id)
);
INSERT INTO permissions (role_id, resource_name, can_view, can_edit_email, can_edit_password, can_edit_cpf, can_edit_status) VALUES (1, 'regular_user', true, true, true, false, false);
INSERT INTO permissions (role_id, resource_name, can_view, can_edit_email, can_edit_password, can_edit_cpf, can_edit_status) VALUES (2, 'administrator', true, true, true, true, true);