Unix Technical Forum

PK & FK & Index Question

This is a discussion on PK & FK & Index Question within the pgsql Sql forums, part of the PostgreSQL category; --> Hi All, Assume the following have a one-to-one relationship: team_contact team_contact_id (PK) first_name last_name ... team_contact_contacts team_contact_id (FK) home_phone ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 05:52 PM
L D
 
Posts: n/a
Default PK & FK & Index Question


Hi All,

Assume the following have a one-to-one relationship:

team_contact
team_contact_id (PK)
first_name last_name
...

team_contact_contacts
team_contact_id (FK)
home_phone work_phone
...


Should I set the latter table's FK also to PK? If so, do I need to set an index on the FK even though it's also the primary key?

Alternatively, I could just add a UK contraint to FK and do away with PK, right?

Thanks.

--Lenard



__________________________________________________ _______________
Connect to the next generation of MSN Messenger*
http://imagine-msn.com/messenger/lau...=wlmailtagline
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 05:52 PM
=?UTF-8?Q?Rodrigo_De_Le=C3=B3n?=
 
Posts: n/a
Default Re: PK & FK & Index Questio

On 9/2/07, L D <lenardd@hotmail.com> wrote:
> Should I set the latter table's FK also to PK?


It's sane.

> If so, do I need to set an index on the FK even though it's also the primary key?


No need to do so.

---------------------------(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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com