Finish admin dashboard and update sql code

This commit is contained in:
estherdev03
2025-04-20 07:50:57 -06:00
parent 7a2250369e
commit 26cd50ab6f
16 changed files with 766 additions and 57 deletions

View File

@@ -67,40 +67,42 @@ VALUES
(1, TRUE, TRUE),
(2, TRUE, FALSE);
-- Insert Categories
-- Insert Categories
INSERT INTO
Category (CategoryID, Name)
Category (Name)
VALUES
(1, 'Textbooks'),
(2, 'Electronics'),
(3, 'Furniture'),
(4, 'Clothing'),
(5, 'Sports Equipment'),
(6, 'Musical Instruments'),
(7, 'Art Supplies'),
(8, 'Kitchen Appliances'),
(9, 'Gaming'),
(10, 'Bicycles'),
(11, 'Computer Accessories'),
(12, 'Stationery'),
(13, 'Fitness Equipment'),
(14, 'Winter Sports'),
(15, 'Lab Equipment'),
(16, 'Camping Gear'),
(17, 'School Supplies'),
(18, 'Office Furniture'),
(19, 'Books (Non-textbook)'),
(20, 'Math & Science Resources'),
(21, 'Engineering Tools'),
(22, 'Backpacks & Bags'),
(23, 'Audio Equipment'),
(24, 'Dorm Essentials'),
(25, 'Smartphones & Tablets'),
(26, 'Winter Clothing'),
(27, 'Photography Equipment'),
(28, 'Event Tickets'),
(29, 'Software Licenses'),
(30, 'Transportation (Car Pool)');
('Textbooks'),
('Electronics'),
('Furniture'),
('Clothing'),
('Sports Equipment'),
('Musical Instruments'),
('Art Supplies'),
('Kitchen Appliances'),
('Gaming'),
( 'Bicycles'),
( 'Computer Accessories'),
( 'Stationery'),
( 'Fitness Equipment'),
( 'Winter Sports'),
( 'Lab Equipment'),
( 'Camping Gear'),
( 'School Supplies'),
( 'Office Furniture'),
( 'Books (-textbook)'),
( 'Math & Science Resources'),
( 'Engineering Tools'),
( 'Backpacks & Bags'),
( 'Audio Equipment'),
( 'Dorm Essentials'),
( 'Smartphones & Tablets'),
( 'Winter Clothing'),
( 'Photography Equipment'),
( 'Event Tickets'),
( 'Software Licenses'),
( 'Transportation (Car Pool)');
-- Insert Products
INSERT INTO

View File

@@ -24,7 +24,7 @@ CREATE TABLE UserRole (
-- Category Entity (must be created before Product or else error)
CREATE TABLE Category (
CategoryID INT PRIMARY KEY,
CategoryID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL
);
@@ -38,15 +38,15 @@ CREATE TABLE Product (
Description TEXT,
CategoryID INT NOT NULL,
Date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (CategoryID) REFERENCES Category (CategoryID)
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE SET NULL,
FOREIGN KEY (CategoryID) REFERENCES Category (CategoryID) ON DELETE SET NULL
);
-- Fixed Image_URL table
CREATE TABLE Image_URL (
URL VARCHAR(255),
ProductID INT,
FOREIGN KEY (ProductID) REFERENCES Product (ProductID)
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE CASCADE
);
-- Fixed Review Entity (Many-to-One with User, Many-to-One with Product)
@@ -60,8 +60,8 @@ CREATE TABLE Review (
AND Rating <= 5
),
Date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (ProductID) REFERENCES Product (ProductID)
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE SET NULL,
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE CASCADE
);
-- Transaction Entity (Many-to-One with User, Many-to-One with Product)
@@ -71,8 +71,8 @@ CREATE TABLE Transaction (
ProductID INT,
Date DATETIME DEFAULT CURRENT_TIMESTAMP,
PaymentStatus VARCHAR(50),
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (ProductID) REFERENCES Product (ProductID)
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE CASCADE,
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE SET NULL
);
-- Recommendation Entity (Many-to-One with User, Many-to-One with Product)
@@ -81,8 +81,8 @@ CREATE TABLE Recommendation (
UserID INT,
RecommendedProductID INT,
Date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (RecommendedProductID) REFERENCES Product (ProductID)
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE CASCADE,
FOREIGN KEY (RecommendedProductID) REFERENCES Product (ProductID) ON DELETE CASCADE
);
-- History Entity (Many-to-One with User, Many-to-One with Product)
@@ -91,8 +91,8 @@ CREATE TABLE History (
UserID INT,
ProductID INT,
Date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (ProductID) REFERENCES Product (ProductID)
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE CASCADE,
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE CASCADE
);
-- Favorites Entity (Many-to-One with User, Many-to-One with Product)
@@ -100,8 +100,8 @@ CREATE TABLE Favorites (
FavoriteID INT AUTO_INCREMENT PRIMARY KEY,
UserID INT,
ProductID INT,
FOREIGN KEY (UserID) REFERENCES User (UserID),
FOREIGN KEY (ProductID) REFERENCES Product (ProductID),
FOREIGN KEY (UserID) REFERENCES User (UserID) ON DELETE CASCADE,
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE CASCADE,
UNIQUE (UserID, ProductID)
);
@@ -110,8 +110,8 @@ CREATE TABLE Product_Category (
ProductID INT,
CategoryID INT,
PRIMARY KEY (ProductID, CategoryID),
FOREIGN KEY (ProductID) REFERENCES Product (ProductID),
FOREIGN KEY (CategoryID) REFERENCES Category (CategoryID)
FOREIGN KEY (ProductID) REFERENCES Product (ProductID) ON DELETE CASCADE,
FOREIGN KEY (CategoryID) REFERENCES Category (CategoryID) ON DELETE CASCADE
);
-- Login Authentication table