Home » Other » Training & Certification » Help with creating tables and primary keys...? (sql plus oracle 9i)
Help with creating tables and primary keys...? [message #297606] |
Fri, 01 February 2008 12:40 |
jlbovo
Messages: 8 Registered: February 2008
|
Junior Member |
|
|
For an assignment i have created three dimension tables and on fact table.
The 3 dim. tables are market, product, and time. The fact table is called fact.
the market table has market_id, city, state, and region. Product tables has product_id, name, category, and price. Time table has time_id, week, month, and quarter.
The fact table has the three foreign keys ( market_id, product_id, Time_id.) and a sales_amt attribute.
I had created all 3 of the dimension tables, but i am having trouble with my fact table.
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M1', 'P1', 'T1', '1000');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M1', 'P2', 'T1', '2000');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M1', 'P3', 'T1', '1500');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M1', 'P4', 'T1', '2500');
...and then
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M2', 'P1', 'T1', '500');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M2', 'P2', 'T1', '800');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M2', 'P3', 'T1', '0');
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M2', 'P4', 'T1', '3333');
but i run into trouble when i start my next insert statements.
INSERT INTO FACT ( MARKET_ID, PRODUCT_ID, TIME_ID, SALES_AMT)
VALUES ('M3', 'P1', 'T1', '5000');
i get this error....and i have no idea since the other values i enetered i had no problem. ERROR at line 1:
ORA-02291: integrity constraint (JBOVO.FACT_MARKET_ID_FK) violated - parent key
not found
does anyone have a clue to why i am getting this error ?? Your help would be greatly apperciated...thanks !
|
|
|
|
|
Goto Forum:
Current Time: Thu Nov 21 15:06:23 CST 2024
|