I am pretty new to databases and SQL in general and have a pretty important task that I do not know how to solve.
Given that I have a Company (Company A) with three different subsidiaries (Sub A, Sub B, Sub C). All three subsidiaries produce the same products which can be divided into three product categories:
- Product Category A
- Product Category B
- Product Category C
My task is to create a star scheme that allows me to get the following information: Total Revenues of Sub A and Sub B for every Product from Product Category B.
The needed format of the result is a table containing three columns "Subsidiary Name", "Product Name" and "Revenue".
What I have been trying to do so far, is to create the following Fact Table, Dimension and Keys. The Primary Keys of the Dimensions are connected to the Foreign Keys of my Fact Table.
So my questions are:
Am I even on the right track or is this approach completely wrong?
How would I actually "fill" my tables with example data to be able to write a query that answers the given question above?
How would such a query look like?
For now, I am using a local MySQL server created with XAMPP and am connecting to this using IntelliJ IDEA Ultimate 2016. The diagramm above has also bee created using this software.
I hope that someone is able and willing to help me.
Also, please forgive any mistakes (or please tell me what I did wrong) as I am both new to SQL and especially new to Stackoverflow.
Kind regards
Edit:
I have used a different tool to create and visualize my tables. Also, as fenix mentioned, I have added several different Dimensions such as a Time/Date Table. However, in order to solve my task, I suppose I only need the two Dimensions dimCompany (Which represents the different subsidiaries) and dimProduct.