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 Go to next message
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 !
Re: Help with creating tables and primary keys...? [message #297609 is a reply to message #297606] Fri, 01 February 2008 12:49 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It seems that there's no "M3" market in the 'market' table.
Re: Help with creating tables and primary keys...? [message #297716 is a reply to message #297606] Sat, 02 February 2008 20:36 Go to previous message
jlbovo
Messages: 8
Registered: February 2008
Junior Member
ABSOLUTELY !!

Funny me didn't double check the data they entered in to the Market Table. I had a small typo (n3) by accident. I'm glad some caught this thanks. I noticed it soon after I posted this msg.

Thanks for the reply - Justin
Previous Topic: OCP exam
Next Topic: Need Learning Material (merged)
Goto Forum:
  


Current Time: Sat Dec 28 13:40:56 CST 2024