Question about foreign key

From: Terence Leung <tcmleung(at)yahoo(dot)com>
To: pgsql-general(at)PostgreSQL(dot)org
Subject: Question about foreign key
Date: 2002-11-06 11:49:49
Message-ID: 20021106114949.69045.qmail@web40706.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear sir,
Hi, I am Terence and using Postgresql 7.0 in linux
server and the web server can connect the database.
I want to ask one question:
I have created two tables
1.
CREATE TABLE sys_user (
id serial primary key,
login_name varchar(32),
password varchar(32)
)

2.
CREATE TABLE sys_quest_list (
id serial primary key,
owner_id int4,
quest_name varchar(100)
)

I add a foreign to sys_quest_list

ALTER TABLE sys_quest_list ADD CONSTRAINT sqloifk
foreign key(owner_id) REFERENCES sys_user(id);

The sys_quest_list.owner_id is the foreign key to
sys_user.id

When I do the select SQL like this
"select login_name,quest_name FROM sys_quest_list
JOIN sys_user ON owner_id=sys_user.id"

Can the added foreign key improve the above sql
performance so that it can search faster
or the foreign key can only maintain the data
integrity but cannot make the search faster?

Your help would be much appreciated.
Looking forward to your reply.

Thank you very much

=====
Yours sincerely,
Leung Chun Man, Terence

Mobile: (852) 9273 9176
Homepage: http://tcmleung.uhome.net ,
http://www.dynamicdrive.com/dynamicindex4/filter/index.htm

__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Simeó Reig 2002-11-06 12:02:28 CURRENT_TIME
Previous Message Florian Litot 2002-11-06 11:17:39 i have got an error