Hi Guys
I am doing an assignment to create a data warehouse. This is the first time I have had to create one using Oracle, I apologise if some of my questions seem stupid. But I am hoping I can learn a lot from this.
I was given two flat files as spreadsheets and I imported them into Oracle and when doing so created two tmp tables. The column names for boths spreadsheets/ tmp_tables are id, location,2002_03,2004_05,2005_06,flag and crime_type.
I have then moved the location types into three different dimension tables, region_dim, county_dim and town_dim. I also have a crime_dim which is a table that holds crime_type and a date_dim table that holds the years from the tmp_tables. I inserted these with an INSERT statement and NOT a SELECT AS like the other ones. I now need to create my FACT table which is where I have an issue. The statement I am trying to run:
Quote:
Create table police_fact(
date_id NUMBER (2),
crime_id NUMBER (2),
region_id NUMBER (2),
county_id NUMBER (2),
town_id NUMBER (2),
total_offences NUMBER (10),
CONSTRAINT fk_date
FOREIGN KEY(date_id)
REFERENCES date_dim(date_id),
CONSTRAINT fk_crime
FOREIGN KEY(crime_id)
REFERENCES crime_dim(crime_id),
CONSTRAINT fk_region
FOREIGN KEY(region_id)
REFERENCES region_dim(region_id),
CONSTRAINT fk_county
FOREIGN KEY(county_id)
REFERENCES county_dim(county_id),
CONSTRAINT fk_town
FOREIGN KEY(town_id)
REFERENCES town_dim(town_id));
|
When I try and run this i get an error:
Quote:
|
ORA-02270: no matching unique or primary key for this column-list
|
In all the examples I have seen of a FACT table, i haven't seen them with a PK. Can FACT tables have PRIMARY KEYS?? If so is it a good idea to creat a fact_id on this table. I am interested to know the best way of doing this or what anybodies thoughts are.
THe other thing is, from the flat file, which is now the tmp_tables, there is data inside them, so far I have only created the columns in the dimension tables, I havent done anything with the data. Where do I put this, where is it stored or how do I move it? As much as I read about creating a DW and Star Schema, what to do with the actual data and how to do it is the most confusing thing. If anyone can help and advise me I would be most grateful. I really appreciate your time, sorry for such a long post.
kind regards