Re: Stuck on Foreign Keys

Поиск
Список
Период
Сортировка
Искать
От
Benjamin Smith
Тема
Re: Stuck on Foreign Keys
Дата
Msg-id
200709192159.47855.ben@schoolpathways.com
Ответ на
Список
Дерево обсуждения
Stuck on Foreign Keys Chester <chester@hica.com.au>
Re: Stuck on Foreign Keys Benjamin Smith <ben@schoolpathways.com>
Re: Stuck on Foreign Keys "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: Stuck on Foreign Keys Michael Glaesemann <grzm@seespotcode.net>
Re: Stuck on Foreign Keys Chester <chester@hica.com.au>
Re: Stuck on Foreign Keys "Phoenix Kiula" <phoenix.kiula@gmail.com>
On Wednesday 19 September 2007, Chester wrote:
> 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".

This foreign key constraint that every instance of clients.ticode must have a 
corresponding (unique) titles.ticode. But you don't - there are records in 
clients where there's a ticode value that's not found in titles.ticode. 

Cheers! 

-Ben 

-- 
I kept looking for somebody to solve the problem.
Then I realized - I am somebody. 
-- Author Unknown

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

В списке pgsql-general по дате отправления
От: Bastien Continsouzas
Дата:
От: SunWuKung
Дата:
FAQ