Suppose that a data warehouse consists of the three dimensions time, doctor, and patient, and the two measures count and charge, where a charge is the fee that a doctor charges a patient for a visit. a) Draw a schema diagram for the above data warehouse using one of the schemas. [star, snowflake, fact constellation] b) Starting with the base cuboid [day, doctor, patient], what specific OLAP operations should be performed in order to list the total fee collected by each doctor in 2004? c) To obtain the same list, write an SQL query assuming the data are stored in a relational database with the schema fee (day, month, year, doctor, hospital, patient, count, charge)
Solution:
a) Star Schema is shown in the figure below:
b) First, we should use the roll-up operation to get the year 2004(rolling-up from the day then month to a year). After getting that, we need to use the slice operation to select (2004). Second, we should use roll-up operation again to get all patients. Then, we need to use the slice operation to select (all). Finally, we get a list of the total fee collected by each doctor in 2004. So,
1. roll up from day to month to year
2. slice for year = “2004”
3. roll up on patient from the individual patient to all
4. slice for patient = “all”
5. get the list of the total fees collected by each doctor in 2004
c) Select doctor, Sum(charge)
From fee
Where year = 2004
Group by doctor
Comments
Post a Comment