|
|
Sponsor |
Re: [SQL] Urgent - SQL Unique constraint error (long): msg#00120db.postgresql.novice
Stephan, Thanks for the response but the answer is no. Owing to the ongoing issue with inherited tables in 7.x I have opted to create three tables: Contains generic traits regardless of "class or role". Person -> PK person_id Staff as certain "class" of person. Staff -> PK staff_id FK person_id Contact as another "class" of person. Contact -> PK contact_id FK person_id Phone numbers relate to any "class" but are related back to the originator by using "person_id". Darrin -----Original Message----- From: Stephan Szabo [mailto:sszabo@xxxxxxxxxxxxxxxxxxxxxxx] Sent: August 19, 2002 12:41 PM To: Darrin Domoney Cc: pgsql-sql@xxxxxxxxxxxxxx; pgsql-novice@xxxxxxxxxxxxxx; pgsql-admin@xxxxxxxxxxxxxx Subject: Re: [SQL] Urgent - SQL Unique constraint error (long) On Mon, 19 Aug 2002, Darrin Domoney wrote: > An admitted newbie to postgresql I am trying to commit a new design > my development server using pgAdminII. > > Everything appears to work OK but I am having real grief with my > SQL generating errors - most of which I have cleared myself but > one that I am unsure how to handle: > > UNIQUE constraint for matching given keys for referenced table "staff" > not found > > Below is the SQL code that I am tring to load to build out my database > skeleton: > > CREATE TABLE staff > ( > staff_id serial NOT NULL, > person_id int NOT NULL, > active_staff boolean NOT NULL, > pay_rate decimal(8,2), > discounted_rate decimal(8,2), > discount_break int, > organization_id int NOT NULL, > PRIMARY KEY (staff_id) > ); > ALTER TABLE phone_number ADD CONSTRAINT staff_phone > FOREIGN KEY ( person_id ) > REFERENCES staff ( person_id ) > NOT DEFERRABLE; The target of a references constraint must be in a unique constraint. Here you're referencing person_id which is not the key of staff. Are you sure you don't want to be linking staff_id instead? ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Urgent - SQL Unique constraint error (long), paul butler |
|---|---|
| Next by Date: | Re: Urgent - SQL Unique constraint error (long), Darrin Domoney |
| Previous by Thread: | Urgent - SQL Unique constraint error (long), Darrin Domoney |
| Next by Thread: | Re: [ADMIN] [SQL] Urgent - SQL Unique constraint error (long), Darrin Domoney |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|