Link to home
Start Free TrialLog in
Avatar of manikandan689
manikandan689

asked on

Foreign key problem in DB2 database

hi
        i have a table called complaints

complaints(uid ,cid,subject description) where uid and cid are composite primary key

and another table called

complaints_access(uid,cid, creationtime)where again  uid and cid are composite primary key

where cid of complaints_access refers to cid of cid of complaints(foreign key).


now it shows the following error

SQL0573N  A column list specified in the references clause of constraint
"CID..." does not identify a unique constraint of the parent table


please help!
ASKER CERTIFIED SOLUTION
Avatar of ssisworo
ssisworo
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
foreign keys can only reference primary keys or unique indexes,
so if you want your foreign key to be on cid, you need to create a unique index on cid
Avatar of Member_2_2484401

Both of the above comments should help you solve your immediate problem.

But, from a design standpoint, you may want to investigate whether there two table should be rolled up into one table. Obviously, I don't know the full background of what you're trying to accomplish, but it appears that the creationTime attribute more likely belongs in the parent table (complaints).

HTH,
DaveSlash