some cleanup

This commit is contained in:
minhtrannhat 2024-07-24 17:10:26 -04:00
parent 7ae9cca86f
commit 4b1c775b10
3 changed files with 8 additions and 9 deletions

2
.idea/misc.xml generated
View File

@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22 (WSL) (2)" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22 (WSL) (3)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

BIN
diagram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

View File

@ -5,7 +5,7 @@ USE nplo_db;
-- Create Member table -- Create Member table
CREATE TABLE Member CREATE TABLE Member
( (
MemberID INT PRIMARY KEY AUTO_INCREMENT, MemberID INT PRIMARY KEY AUTO_INCREMENT UNIQUE,
FirstName VARCHAR(50) NOT NULL, FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL, LastName VARCHAR(50) NOT NULL,
MiddleInitial CHAR(1), MiddleInitial CHAR(1),
@ -22,7 +22,7 @@ CREATE TABLE Member
-- Create Donations table -- Create Donations table
CREATE TABLE Donations CREATE TABLE Donations
( (
DonationID INT PRIMARY KEY AUTO_INCREMENT, DonationID INT PRIMARY KEY AUTO_INCREMENT UNIQUE,
DonorID INT, DonorID INT,
DonationDate DATE NOT NULL, DonationDate DATE NOT NULL,
DonationType ENUM ('Money', 'Products') NOT NULL, DonationType ENUM ('Money', 'Products') NOT NULL,
@ -33,7 +33,7 @@ CREATE TABLE Donations
-- Create Products table -- Create Products table
CREATE TABLE Products CREATE TABLE Products
( (
ProductID INT PRIMARY KEY AUTO_INCREMENT, ProductID INT PRIMARY KEY AUTO_INCREMENT UNIQUE,
Description TEXT, Description TEXT,
DonationDate DATE, DonationDate DATE,
SellingPrice DECIMAL(10, 2), SellingPrice DECIMAL(10, 2),
@ -48,7 +48,7 @@ CREATE TABLE Products
-- If DeliverToCity is NOT NULL, then this sale needs to be delivered -- If DeliverToCity is NOT NULL, then this sale needs to be delivered
CREATE TABLE Sales CREATE TABLE Sales
( (
SaleID INT PRIMARY KEY AUTO_INCREMENT, SaleID INT PRIMARY KEY AUTO_INCREMENT UNIQUE,
SaleDate DATE NOT NULL, SaleDate DATE NOT NULL,
TotalAmount DECIMAL(10, 2) DEFAULT 0, TotalAmount DECIMAL(10, 2) DEFAULT 0,
ClientID INT, ClientID INT,
@ -71,7 +71,7 @@ CREATE TABLE SalesItems
-- Create Employees table -- Create Employees table
CREATE TABLE Employees CREATE TABLE Employees
( (
EmployeeID INT PRIMARY KEY, EmployeeID INT PRIMARY KEY UNIQUE,
JobTitle ENUM ('President', 'Vice-President', 'Cashier', 'Other') NOT NULL, JobTitle ENUM ('President', 'Vice-President', 'Cashier', 'Other') NOT NULL,
Salary DECIMAL(10, 2), Salary DECIMAL(10, 2),
FOREIGN KEY (EmployeeID) REFERENCES Member (MemberID) FOREIGN KEY (EmployeeID) REFERENCES Member (MemberID)
@ -80,7 +80,7 @@ CREATE TABLE Employees
-- Create Expenses table -- Create Expenses table
CREATE TABLE Expenses CREATE TABLE Expenses
( (
ExpenseID INT PRIMARY KEY AUTO_INCREMENT, ExpenseID INT PRIMARY KEY AUTO_INCREMENT UNIQUE,
ApprovedByID INT, ApprovedByID INT,
PaymentDate DATE NOT NULL, PaymentDate DATE NOT NULL,
Amount DECIMAL(10, 2) NOT NULL, Amount DECIMAL(10, 2) NOT NULL,
@ -387,6 +387,5 @@ WHERE m.MemberType = 'Client'
FROM Sales FROM Sales
WHERE SaleDate >= '2024-01-01') WHERE SaleDate >= '2024-01-01')
GROUP BY m.MemberID GROUP BY m.MemberID
HAVING HAVING COUNT(s.SaleID) > 0
COUNT(s.SaleID) > 0
ORDER BY TotalSalesAmount DESC; ORDER BY TotalSalesAmount DESC;