An ASP.NET Core application project with ASP.NET Razor Pages content.
Based on BoostMyTool tutorials:
Create a database with the name of your chioce.
Search the code, replace ALIMPC
and URSdatabase
with your own Server name and Database name respectively.
CREATE TABLE users (
userId INT PRIMARY KEY IDENTITY,
username VARCHAR (100) NOT NULL,
email VARCHAR (150) NOT NULL UNIQUE,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE roles (
roleId INT PRIMARY KEY IDENTITY,
roleName VARCHAR(50) NOT NULL UNIQUE
);
CREATE TABLE status (
statusId INT PRIMARY KEY IDENTITY,
statusName VARCHAR(50) NOT NULL UNIQUE
);
CREATE TABLE userRoles (
userId INT,
roleId INT,
PRIMARY KEY (userId, roleId),
FOREIGN KEY (userId) REFERENCES users(userId),
FOREIGN KEY (roleId) REFERENCES roles(roleId)
);
CREATE TABLE userStatus (
userId INT,
statusId INT,
PRIMARY KEY (userId, statusId),
FOREIGN KEY (userId) REFERENCES users(userId),
FOREIGN KEY (statusId) REFERENCES status(statusId)
);
INSERT INTO status (statusName)
VALUES
('active'),
('deactive');
INSERT INTO roles (roleName)
VALUES
('su'),
('admin'),
('customer'),
('guest');
INSERT INTO users(username, email)
VALUES
('Bill Gates', '[email protected]'),
('Elon Musk', '[email protected]'),
('Steve Jobs', '[email protected]'),
('Shuhei Yoshida', '[email protected]'),
('John McAfee', '[email protected]'),
('Phil Spencer', '[email protected]');
INSERT INTO userStatus(userId, statusId)
VALUES
(1, 1),
(2, 1),
(3, 2),
(4, 1),
(5, 2),
(6, 1);
INSERT INTO userRoles(userId, roleId)
VALUES
(1, 1),
(2, 2),
(3, 2),
(4, 3),
(5, 4),
(6, 3);
For major changes, please open an issue first to discuss what you would like to change.
October 2023