I am a newbie and would appreciate suggestions/material to research
I have 3 types on information in a single table
-
problems
-
reasons
-
fixes
problem data is related to reasons by 1 to many
reasons data is related to fixes by 1 to many
I am thinking of creating a dimension table for dates as mentioned here
How could I design a star schema out of it? As of now the entire data is in a single table (all joined together)
#####################
update 1 – example data and my 1st solution below. Please guide
my columns are
problem id
problem description
problem associate department
problem due date
reason id
reason description
reason associated person
reason due date
fix id
fix description
fix owning employee
fix due date
example data
+------------+---------------------+------------------------------+------------------+-----------+--------------------------+--------------------------+-----------------+--------+----------------------+---------------------+--------------+
| problem id | problem description | problem associate department | problem due date | reason id | reason description | reason associated person | reason due date | fix id | fix description | fix owning employee | fix due date |
+------------+---------------------+------------------------------+------------------+-----------+--------------------------+--------------------------+-----------------+--------+----------------------+---------------------+--------------+
| 1 | wrong customer info | sales | 1-Jan-21 | 1 | customer gave wrong info | a | 15-Dec-20 | 1 | contact customer | bb | 10-Dec-20 |
| 1 | wrong customer info | sales | 1-Jan-21 | 2 | customer gave wrong info | a | 15-Dec-20 | 2 | verify customer info | cc | 15-Dec-20 |
| 1 | wrong customer info | sales | 1-Jan-21 | 1 | data entry error | b | 16-Dec-20 | 1 | correct data entry | bb | 16-Dec-20 |
| 1 | wrong customer info | sales | 1-Jan-21 | 1 | database wrong join | c | 20-Dec-20 | 1 | fix join | aa | 19-Dec-20 |
| 1 | wrong customer info | sales | 1-Jan-21 | 2 | database wrong join | c | 20-Dec-20 | 2 | something else | dd | 19-Dec-20 |
| 1 | wrong customer info | sales | 1-Jan-21 | 3 | database wrong join | c | 20-Dec-20 | 3 | modify tables | bb | 19-Dec-20 |
+------------+---------------------+------------------------------+------------------+-----------+--------------------------+--------------------------+-----------------+--------+----------------------+---------------------+--------------+
I am thinking of a design like below. all joins would be 1:1 in case of fact table
. In case of fact table2 calendar
there would be 1:many join as that fact table would have one row per date while the dim tables could have same date on multiple rows
Best Answer
A very basic star-schema for your situation might look like this:
The T-SQL statements to create the dimension tables for this schema look like:
The fact table, which you seem to have left out of your question, and I've named
incidents
, looks like:incidents
references the dimension tables such that you are storing the bare minimum of information in the fact table. Thefix_id
column is referenced in theincidents
table to indicate which of the possibly many fixes was accepted as the actual fix used in this incident. Since each fix is related to only a single reason, you can infer the reason from the fix. I've included a discrete column to indicate the problem in this table to enable incidents that don't yet have a fix.You could add a
reason_id
foreign-key column to theincidents
table if desired. For instance, maybe you identify a reason prior to determining the fix.