Results 1 to 4 of 4
- 10-08-2009, 04:15 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
creating many-many relationships in javadb
Hi,
I need to create some many-many relationships between two tables and want to use a link table to do this.
It is rather simple and standard but can't figure out how to do this in javadb.
tab1
pk1
..
..
tab2
pk2
....
tab1_tab2
pf_k1
pf_k2
/* the above represent a compound primary key */
How on earth do I create the above in javadb / derbydb?
I've tried the following:-
Alter table tab1 add constraint tab1_fk foreign key (pk1) references tab1_tab2 (pf_k1)
and likewise for tab2 and pk2 but I get the following error:-
"Error code -1, SQL state X0Y44: Constraint 'TAB1_FK' is invalid: there is no unique or primary key constraint on table '"APP"."DEL_SEM"' that matches the number and types of the columns in the foreign key."
I've tried so many combinations and searched and searched the web to no avail. Hoping someone here can help.....
thanks,
- 10-08-2009, 04:17 PM #2
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
sorry the error is:-
"Error code -1, SQL state X0Y44: Constraint 'TAB1_FK' is invalid: there is no unique or primary key constraint on table "tab1_tab2"' that matches the number and types of the columns in the foreign key."
- 10-08-2009, 09:07 PM #3
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
pf_k1 needes to be defined as a prmary key or as a unique constraint (which is exactly what that exception says) before you can reference it as a foreign key.
- 10-08-2009, 10:27 PM #4
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Creating files stopped creating...
By Dieter in forum Advanced JavaReplies: 3Last Post: 09-25-2009, 11:45 PM -
Need help creating a table
By Knizz in forum SWT / JFaceReplies: 3Last Post: 07-18-2009, 03:46 AM -
load driver in javaDB
By kulangotski in forum New To JavaReplies: 1Last Post: 02-20-2009, 07:15 PM -
JavaDB Help
By Sysem in forum New To JavaReplies: 5Last Post: 05-29-2008, 09:21 PM -
JavaDB Installation
By PhilArmstrong in forum New To JavaReplies: 6Last Post: 05-13-2008, 02:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks