added users and roles table to ddl

This commit is contained in:
Im_Alpha 2021-12-13 15:39:38 -08:00
parent c72af8ccb6
commit 9e1ef7bcab

152
src/dbCode/fullDDL.txt Normal file
View File

@ -0,0 +1,152 @@
create database Hobby;
use hobby;
create table users
(
UserName varchar(50) charset utf8mb3 not null
primary key,
Password varchar(50) charset utf8mb3 null,
RoleID int auto_increment,
IsActive int default 1 null,
CreatedBy varchar(50) charset utf8mb3 null,
CreatedDate datetime null,
constraint users_UserName_uindex
unique (UserName),
constraint users_roles_RoleID_fk
foreign key (RoleID) references roles (RoleID)
);
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Colin ', 'Waffle', 'Jacob', '2021-12-13 04:27:42');
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Danny', 'Spartan', 'Jacob', '2021-12-13 04:29:54');
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Jacob', 'Teamhobby1234', 'SystemCreator', '2021-12-13 03:25:14');
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Long', 'Joystick', 'Jacob', '2021-12-13 04:29:57');
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Rifat', 'ApproveDar', 'Jacob', '2021-12-13 04:29:55');
create table roles
(
RoleID int auto_increment
primary key,
Role varchar(50) charset utf8mb3 null,
CreatedBy varchar(200) charset utf8mb3 null,
CreatedDate datetime null
);
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'SystemCreator', '2021-12-13 03:25:14');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:44');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:46');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:49');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:50');
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:51');
alter table users
add constraint users_roles_RoleID_fk
foreign key (RoleID) references roles (RoleID);
SET Global innodb_file_per_table=ON;
-- SET GLOBAL innodb_file_format='Barracuda';
SET GLOBAL innodb_default_row_format='dynamic';
SET GLOBAL innodb_compression_algorithm='zlib';
-- Check for system settings
SHOW VARIABLES LIKE 'innodb_compression_algorithm';
SHOW VARIABLES LIKE 'innodb_default_row_format';
SHOW VARIABLES LIKE '%innodb%';
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
CREATE DATABASE testDB;
-- Hobby DDL
-- Log level table
create table LogLevel
(
LvName varchar(50) not null,
LvComment varchar(500) not null,
constraint LogLevel_pk
primary key (LvName)
);
-- Log categories table
create table LogCategories
(
catName varchar(50) not null,
catComment varchar(255) not null,
constraint LogCategories_pk primary key (catName)
);
-- DDL for log table
create table Log
(
LtimeStamp datetime default CURRENT_TIMESTAMP null,
logID int auto_increment not null,
LvName varchar(50) not null,
catName varchar(50) not null,
userOP varchar(50) not null,
logMessage varchar(255) not null,
constraint LogLvName_fk foreign key (LvName) references loglevel (LvName),
constraint LogCatName_fk foreign key (catName) references logcategories (catName),
constraint Log_pk primary key (logID)
);
create table Archive
(
LtimeStamp datetime null,
logID int not null,
LvName varchar(50) not null,
catName varchar(50) not null,
userOP varchar(50) not null,
logMessage varchar(255) not null,
constraint Archive_pk primary key (logID)
)
ENGINE=InnoDB
PAGE_COMPRESSED=1
PAGE_COMPRESSION_LEVEL=9;
drop table archive;
-- Dummy data for testing purposes
-- Log categories data
INSERT into logcategories(catName, catComment) values
('View', 'view layer'),
('Business', 'business layer'),
('Server', 'server layer'),
('Data', 'data layer');
-- Log level data
INSERT into loglevel(lvname, lvcomment) values
('Info', 'some sys flow'),
('Debug', 'info for fixing bugs'),
('Warning', 'track system failure'),
('Error', 'some sys errors');
-- Log table data
INSERT into log(lvname, catname, userop, logmessage) values
('Info', 'View', 'create some projects', 'new account created'),
('Info', 'Business', 'create some projects', 'new projects made'),
('Info', 'View', 'log out', 'log out successful'),
('Info', 'Business', 'log in', 'log in successfully'),
('Info', 'View', 'search for projects', 'result return');
select * from logcategories;
select * from log;