I'm working on my first DW project and would appreciate some help.
I’m at the stage now where I want to populate my fact table with already-existing data.
(using Snowflake btw)
The way I intend for it to come out is as such;
DVDID GenreID RatingID MonthID DVDTOTALQUANTITY etc...
1 1 1 1 200
The problem I’m having is understanding how to join all the dimensions together and load them into the fact table - I can join dvdid, generic and ratingid because they’re all referenced in the dvd table, but MONTH is a new dimension I created for this particular grain, and I don’t know how I’m exactly meant to link that in the fact table - if that makes sense.
I’m attaching my ERD diagram for this particular fact below, and the SQL code I have so far.
Any pointers on how I should proceed?
Currently my code is this...
insert into NETFLIX.NETFLIX_SCHEMA_DWH_NETFLIX.FACT_INVENTORY (dvdid, genreid, ratingid, dvdtotalquantity, dvdtotallost, dvdtotalrent, dvdstock)
select
d.dvdid,
g.genreid,
r.ratingid,
sum(dvdquantityonhand) as dvdtotalquantity,
sum(dvdquantitylost) as dvdtotallost,
sum(dvdquantityonrent) as dvdtotalrent,
((1 - (sum(dvdquantityonrent) / sum(dvdquantityonhand))) * 100) as dvdstock
from NETFLIX.NETFLIX_SCHEMA_STG_TABLES.STG_DVD d
join NETFLIX.NETFLIX_SCHEMA_STG_TABLES.STG_GENRE g on d.genreid = g.genreid
join NETFLIX.NETFLIX_SCHEMA_STG_TABLES.STG_RATING r on r.ratingid = d.ratingid
group by (d.dvdid, g.genreid, r.ratingid)
trying to figure out how to implement month
