-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
39 lines (34 loc) · 1.03 KB
/
schema.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
CREATE DATABASE IF NOT EXISTS inventory_db;
USE inventory_db;
CREATE TABLE IF NOT EXISTS user (
id int not null auto_increment,
email varchar(255) not null,
name varchar(255) not null,
password varchar(255) not null,
primary key (id)
);
CREATE TABLE IF NOT EXISTS product (
id int not null auto_increment,
name varchar(255) not null,
description varchar(255) not null,
price float not null,
created_by int not null,
primary key (id),
foreign key (created_by) references user(id)
);
CREATE TABLE IF NOT EXISTS role (
id int not null auto_increment,
name varchar(255) not null,
primary key (id)
);
CREATE TABLE IF NOT EXISTS user_role (
id int not null auto_increment,
user_id int not null,
role_id int not null,
primary key (id),
foreign key (user_id) references user(id),
foreign key (role_id) references role(id)
);
INSERT INTO role (id, name) VALUES (1, 'admin');
INSERT INTO role (id, name) VALUES (2, 'seller');
INSERT INTO role (id, name) VALUES (3, 'customer');