Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Dear all your solution is incorrect,please check my solution below and edit the code, I think my issue is the connection between diemansions tables and
Dear all
your solution is incorrect,please check my solution below and edit the code, I think my issue is the connection between diemansions tables and fact table, because there is no data appear in Q until Q
Project Tasks:
STEP : Create TSALESMAN Table:
CREATE TABLE TSALESMAN
SALESREPID NUMBER,
SNAME VARCHAR
;
SELECT DISTINCT COALESCESALESREPID AS SALESREPID 'NAME COALESCESALESREPID AS SNAME
FROM ORDERSCOPY;
Project Tasks:
Q : Create all DIMENSION AS MATERIALIZED VIEWS.
: Define a materialized View for DTIME Dimension table.
CREATE MATERIALIZED VIEW MVDTIME
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
AS
SELECT
ROWNUMBER OVER ORDER BY ORDERDATE AS IDTgenerate a unique ID for each row based on ORDERDATE
MONTHNO
QUARTER,
YYear AS YEAR,
ORDERDATE AS ORDERDATE,
MonthName
FROM TDATE
Display the content of the materialized view
SELECT FROM MVDTIME;
: Define the DTIME dimension using its created MV
CREATE TABLE DTIME AS
SELECT DISTINCT
IDT
MONTHNO
QUARTER,
YEAR,
ORDERDATE,
MONTHNAME
FROM MVDTIME;
Add a primary key constraint to the DTIME table
ALTER TABLE DTIME
ADD CONSTRAINT PKDTIME PRIMARY KEY IDT;
: Define the primary key for the MV
ALTER MATERIALIZED VIEW MVDTIME ADD PRIMARY KEY IDT;
: Define a materialized View for DSALESMAN Dimension table
CREATE MATERIALIZED VIEW MVDSALESMAN
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
AS
SELECT
ROWNUMBER OVER ORDER BY SALESREPID AS IDSgenerate a unique ID for each row based on IDS
SNAME
FROM TSALESMAN;
Display the content of the materialized view
SELECT FROM MVDSALESMAN;
: Define the DSALESMAN dimension using its created MV
CREATE TABLE DSALESMAN AS
SELECT DISTINCT
IDS
SNAME
FROM MVDSALESMAN;
Add a primary key constraint to the DSALESMAN table
ALTER TABLE DSALESMAN
ADD CONSTRAINT PKDSALESMAN PRIMARY KEY IDS;
: Define the primary key for the MV
ALTER MATERIALIZED VIEW MVDSALESMAN ADD PRIMARY KEY IDS;
: Define a materialized View for DCUSTOMERS Dimension table
CREATE MATERIALIZED VIEW MVDCUSTOMERS
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
AS
SELECT
ROWNUMBER OVER ORDER BY IDC AS IDCgenerate a unique ID for each row based on IDC
CUSTOMERID
CUSTFIRSTNAME AS CFName,
CUSTLASTNAME AS CLName,
GENDER,
CUSTTYPE AS CType
FROM CUSTOMERCOPY;
Display the content of the materialized view
SELECT FROM MVDCUSTOMERS;
Define the DCUSTOMERS dimension using its created MV
CREATE TABLE DCUSTOMERS AS
SELECT DISTINCT
IDC
CFName,
CLName,
GENDER,
CType
FROM MVDCUSTOMERS;
Add a primary key constraint to the DCUSTOMERS table
ALTER TABLE DCUSTOMERS
ADD CONSTRAINT PKDCUSTOMERS PRIMARY KEY IDC;
Define a materialized View for DORDERS Dimension table
CREATE MATERIALIZED VIEW MVDORDERS
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
AS
SELECT
ROWNUMBER OVER ORDER BY ORDERID AS IDOgenerate a unique ID for each row based on ORDERID
ORDERMODE AS OMode,
ORDERSTATUS AS Status
FROM ORDERSCOPY;
Display the content of the materialized view
SELECT FROM MVDORDERS;
Define the DORDERS dimension using its created MV
CREATE TABLE DORDERS AS
SELECT DISTINCT
IDO
OMode,
Status
FROM MVDORDERS;
Add a primary key constraint to the DORDERS table
ALTER TABLE DORDERS
ADD CONSTRAINT PKDORDERS PRIMARY KEY IDO;
Q & & : Creating the fact table FORDERS
: Create the fact table FORDERS
CREATE TABLE FORDERS
FORDERSID INTEGER,
ORDERAMOUNT DECIMAL
ORDERDATE DATE,
IDC INTEGER,
IDS INTEGER,
IDT INTEGER,
IDO INTEGER,
FOREIGN KEY IDC REFERENCES DCUSTOMERS IDC ON DELETE CASCADE,
FOREIGN KEY IDS REFERENCES DSALESMAN IDS ON DELETE CASCADE,
FOREIGN KEY IDO REFERENCES DORDERS IDO ON DELETE CASCADE,
FOREIGN KEY IDT REFERENCES DTIME IDT ON DELETE CASCADE
;
: Define PK constraint for FORDERSID
ALTER TABLE FORDERS
ADD CONSTRAINT PKFORDERSID PRIMARY KEY FORDERSID;
Q: Create an Oracle Sequence starting with for FORDERSID
CREATE SEQUENCE SEQFORDERS START WITH ;SQL Worksheet
There is no
data?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started