I have an sql table that stores English words and second table that stores meanings of those words in related maner.
Here are some informations about table structures:

Table1 name: Words
WordID int IDENTITY(1,1) NOT NULL, //This is primaryKey
Word varchar(50) NOT NULL,

Table2 name: Meanings
MeaningID int IDENTITY(1,1) NOT NULL, //This is primaryKey
WordID1 int) NOT NULL, //This is foreinKey
WordID2 int) NOT NULL, //This is foreinKey

All I want is that, use the WordID from the table “Words” as the word I want to give a mening and store it in WordID1 column of the table “Meanings”. Also use the WordID from the table “Words” that corresponds to the meaning of the word I select and store it in WordID2 column of the table “Meanings” as meaning of that word.
When I try to insert the record, using sql management object, I receive a forein key conflict constranct.
So can anyone help me overcame this?
Please help!

Recommended Answers

you are trying to insert wordid in wordid1 or wordid2 which do not exites in table words

Jump to Post

All 3 Replies

you are trying to insert wordid in wordid1 or wordid2 which do not exites in table words

I agree with utrivedi. My guess is you've used the graphic environment to join the 2 tables and see only the 2 word fields and it didn't work. What you need to do is insert both words in the Words table and then insert their "relationship" in the Meanings.

I feel that a foriegn key must be a primary key to some other table.WordID is a primary key to words table ,so this column can be used as a foriegn key to meanings table where as wordid1 and wordid2 are not primary keys, so these columns can not be used as foriegn keys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.