How model the fact table
2 posters
Page 1 of 1
How model the fact table
I'm building a DW but I'm not able to design a fact table that show what i need. My design until now is that :
Table: dimPatient
Table: dimSirurgy
Table: dimExam
Table: dimDate
Table: Fact
If you see the rows in the fact table are duplicate. For example I wanna know the cost of the sirurgy but the cube was return the sum of the duplicate rows, probably because its model in the wrong way.
The rule for these tables are that one patient could make only one sirurgy per day, but could do more than one exam in a day.
Thanks in advance
Table: dimPatient
ID_PACIENT | NAME | AGE |
1 | AAA | 18 |
2 | BBB | 21 |
Table: dimSirurgy
ID_SIRURGY | ID_PACIENTE | date_fact | date_pay | COST | nm_description | nm_doctor |
100 | 1 | 2013-01-01 | 2013-06-01 | 10000 | DESC 1 | DOCTOR 1 |
200 | 2 | 2013-05-01 | 2013-06-01 | 15000 | DESC 2 | DOCTOR 2 |
Table: dimExam
ID_EXAM | id_patient | date_fact | nm_description | HOSPITAL |
05 | 1 | 2013-02-01 | DESC 1 | HOSP A |
10 | 1 | 2013-02-01 | DESC 2 | HOSP A |
15 | 2 | 2013-05-01 | DESC 3 | HOSP B |
20 | 2 | 2013-05-01 | DESC 4 | HOSP B |
Table: dimDate
ID_DATE | DATE |
1 | 2013-01-01 |
2 | 2013-02-01 |
3 | 2013-03-01 |
4 | 2013-04-01 |
5 | 2013-05-01 |
6 | 2013-06-01 |
7 | 2013-07-01 |
Table: Fact
ID_PACIENT | ID_SIRURGY | ID_EXAM | ID_DATE | SUM COST |
1 | 100 | NULL | 1 | 10000 |
1 | NULL | 5 | 2 | NULL |
1 | NULL | 10 | 2 | NULL |
2 | 200 | 15 | 5 | 150000 |
2 | 200 | 20 | 5 | 150000 |
If you see the rows in the fact table are duplicate. For example I wanna know the cost of the sirurgy but the cube was return the sum of the duplicate rows, probably because its model in the wrong way.
The rule for these tables are that one patient could make only one sirurgy per day, but could do more than one exam in a day.
Thanks in advance
ftatarli- Posts : 2
Join date : 2013-04-10
Re: How model the fact table
Normally this is modeled at the procedure grain. One row per patient/procedure/date. The costs are recorded as known for that procedure, not a combination of all procedures for a given encounter. Capitated procedures, such as exams could be booked at a standard cost. Recorded as null in your example is another possible method, but can be misleading in clinical analysis and actuarial studies.
Re: How model the fact table
Thank you for your reply ngalemmo.
Just let me see if I understand what you said. My fact table should be like that :
Table: Fact
One row per procedure, indepedent if its in the same day ?
Thanks
Just let me see if I understand what you said. My fact table should be like that :
Table: Fact
ID_PACIENT | ID_SIRURGY | ID_EXAM | ID_DATE | SUM COST |
1 | 100 | NULL | 2 | 10000 |
1 | NULL | 5 | 1 | NULL |
1 | NULL | 10 | 1 | NULL |
2 | 200 | NULL | 5 | 150000 |
2 | NULL | 15 | 5 | NULL |
2 | NULL | 20 | 5 | NULL |
One row per procedure, indepedent if its in the same day ?
Thanks
ftatarli- Posts : 2
Join date : 2013-04-10
Re: How model the fact table
One FK as well, Procedure ID. The procedure dimension would include all procedures (exams, surgeries, dispensing medications, etc...). Procedures are usually identified using CPT or ICD coding systems (or whatever standard coding system in your region).
The dimension would only contain information about the procedure... not the patient or location or booking dates. Those are dimensions that should be referenced from the fact.
The dimension would only contain information about the procedure... not the patient or location or booking dates. Those are dimensions that should be referenced from the fact.
Similar topics
» Single fact table vs multiple fact tables - what is the right way in a dimensional model?
» How to Model Fact table having 1:1 relationship with key Dimension attributes
» General Ledger Fact Table: Dimensional Model
» Factless Fact table to model 1:M relationships between Type 2 SCD
» How to model customers having contracts (factless fact table?)
» How to Model Fact table having 1:1 relationship with key Dimension attributes
» General Ledger Fact Table: Dimensional Model
» Factless Fact table to model 1:M relationships between Type 2 SCD
» How to model customers having contracts (factless fact table?)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum