I have the following SQL Table:
CREATE TABLE SALES
(saleID INT PRIMARY KEY,
grossSalePrice DECIMAL(9,2),
vehicleStatus VARCHAR(10) NOT NULL CHECK (lower(vehicleStatus) IN ('available', 'sold', 'pending')),
saleDate DATE,
saleMileage INT,
customerID INT,
salespersonID INT,
vehicleVIN VARCHAR(25),
CONSTRAINT SALES_FK1 FOREIGN KEY (customerID) REFERENCES CUSTOMERS(customerID),
CONSTRAINT SALES_FK2 FOREIGN KEY (vehicleVIN) REFERENCES VEHICLES(vehicleVIN),
CONSTRAINT SALES_FK3 FOREIGN KEY (salespersonID) REFERENCES SALESPERSONS(salespersonID));
AND I've created the following Star-Schema Dimension Table:
CREATE TABLE TIMES
(saleDay DATE PRIMARY KEY,
dayType VARCHAR(50) NOT NULL);
I need to populate the saleDay
column of the TIMES
table with each saleDate
within the SALES
table. Also, the dayType
column should be completed based on each saleDay
. The values for the dayType
column should be Weekday
, Weekend
, or Holiday
and if the dayType is Holiday
it should trump Weekend
or Weekday
.
To qualify for being a Holiday
, the dates would have to be:
January 1,
January 15,
January 19,
May 28,
July 4,
October 8,
November 11,
November 22,
December 25.
I've been asked to populate the saleDay
and dayType
values via PL/SQL but I have NO Idea where to start or how to accomplish this. Any help/guidance as to how I can complete this is greatly appreciated.