Search Postgresql Archives

Stuck on Foreign Keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I have a question regarding foreign keys, I just cannot get it to create them for me....I must be doing something wrong but I have no idea what that might be :)

I have a table "clients"

clientID (primary)
ticode
Firstname
SecondName

I have a second table "titles"

ticode (primary)
Title

I am trying to create a foreign key on TIcode "clients" table as in below,

ALTER TABLE clients ADD CONSTRAINT the_title FOREIGN KEY (ticode) REFERENCES titles (ticode) ;

I keep getting this error

ERROR: insert or update on table "clients" violates foreign key constraint "the_title"
DETAIL:  Key (ticode)=( ) is not present in table "titles".

Sorry, I have no idea where I  am going wrong...Any help would be great

TIA

C

.





---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux