PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 29th, 2003, 03:08 PM
pablo.gosse pablo.gosse is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 155 pablo.gosse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 6 m 5 sec
Reputation Power: 7
Similar, but slightly different, Foreign Key question

Hi all. I have a question that is similar, but slightly different, than the last question posted about foreign keys.

I have a table cms_areas which will hold area labels, replicating the folders which make up our website. Here's the structure:

Code:
CREATE TABLE "cms_areas" (
	"area_id" SERIAL PRIMARY KEY,
	"parent" integer REFERENCES cms_areas ON UPDATE CASCADE ON DELETE CASCADE,
	"name" character varying(255) NOT NULL,
	"location" character varying(1000) NOT NULL,
	"depth" integer DEFAULT 0 NOT NULL,
	"max_history" integer DEFAULT 3 NOT NULL
);

I want to set up parent as a foreign key to area_id, such that if I have a record with area_id = 1 and parent is null, and another record with area_id 2 and parent = 1, then if the record with area_id = 1 for some reason has its area_id updated, the parent would also update.

While myself I cannot see any situations in which this would arise, if someone can, I would be grateful for some enlightenment here.

What I'm wondering, is since I've not set parent to NOT NULL (since the primary area which will represent the root of our site will not have a parent), will this have any effect on setting parent as a foreign key to the primary key in the same table?

I think in writing out this question I've actually answered my own question, as it seems logical that it wouldn't, but I'm still relatively green in the world of db design and administration, so I value more experienced members' input.

Thanks in advance,
Pablo

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Similar, but slightly different, Foreign Key question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT