473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Foreign key problem

diamond1
Hi

I have a problem with the Foreign key in Postgres 8.1 under Windows XP for example:
I have PERSON table as a superclass and
PERSON_A, PERSON_B, PERSON_C as subclasses
Table_X as an ordinary table
Then I want to link Table_X with PERSON_B, PERSON_C tables
with a Foreign key which is id_no which is PK in the PERSON_B, PERSON_C tables

(I had used inheritance, and I stored the data in the last subclasses for each superclass in my DB)

So, when I want to store the id_no=3 in the Table_X it says that id_no=3 is not exist in the PERSON_B which is actually in PERSON_C table :chomp:

Then I tried to link the id_no in the Table_X with PERSON table (superclass)

it says that id_no=3 is not exist in the PERSON table :chomp:

So, what I have to do?
Apr 17 '07 #1
2 2323
archulu
34
i think this is usefull for u to how to call forghn key in another tables


for primary key assighn ex:
CREATE TABLE Leavetable ( emp_code varchar(25) primary key NOT NULL, fdate date, update date, first_half date, second_half date, no_of_days integer [3] );

for foreighn key asighn ex:
CREATE TABLE Leavetype ( emp_code varchar(25) references leavetable(emp_code), date date, type_of_leave varchar, reason char [50] );
Apr 18 '07 #2
michaelb
534 Expert 512MB
Hi

I have a problem with the Foreign key in Postgres 8.1 under Windows XP for example:
I have PERSON table as a superclass and
PERSON_A, PERSON_B, PERSON_C as subclasses
Table_X as an ordinary table
Then I want to link Table_X with PERSON_B, PERSON_C tables
with a Foreign key which is id_no which is PK in the PERSON_B, PERSON_C tables

(I had used inheritance, and I stored the data in the last subclasses for each superclass in my DB)

So, when I want to store the id_no=3 in the Table_X it says that id_no=3 is not exist in the PERSON_B which is actually in PERSON_C table :chomp:

Then I tried to link the id_no in the Table_X with PERSON table (superclass)

it says that id_no=3 is not exist in the PERSON table :chomp:

So, what I have to do?
Your error looks like a simple foreign key violation.
Read the Foreign Keys section in this man page and also look at the Foreign Keys

If you still has questions after that, please post your table definitions.
Apr 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get...
1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
2
by: Gunnar Vøyenli | last post by:
Hi! For the sake of simplicity, I have three tables, Employee, Department and Work Employee >---- Department \ / \ / ^ ^ Work
10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
1
by: Jason Madison | last post by:
We sometimes get very large databases that we want to cut down to use for testing. The information is all related to a central accounts table. The way I thought of doing this is to grab all...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
10
by: Shawn Chisholm | last post by:
Hi, I am trying to deal with a deadlock situation caused by foreign key references on insert and I was wondering if anyone knows what order the foreign keys are locked (or evaluated) in for a...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
2
by: jarea | last post by:
I have read quite a bit about this error but I have yet to find the solution to my problem. I am trying to execute the following mysql statement: alter table line_items add...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.