identification of foreign key [message #51266] |
Fri, 10 May 2002 23:32 |
pinky
Messages: 26 Registered: May 2002
|
Junior Member |
|
|
Hello,
I have a table say
Location with fields locationid, name and managername
and primary key is locationid
I have another table say worker with fields workerid,workername,locationid,managername and primary key is workerid.In this table locationid is the foreign key which refers table location.Also managername is a redundant field which comes from location table.I added this field intentionally for the sake of better software performance.
Can I identify locationid and managername as foreignkey in worker table after I create a unique index of locationid and managername in location table ?
Or only locationid is the foriegn key and managername is not even part of the foreign key?
Thanks...
|
|
|
Re: identification of foreign key [message #51271 is a reply to message #51266] |
Sat, 11 May 2002 04:17 |
K.SREENIVASAN
Messages: 110 Registered: January 2001 Location: banglore
|
Senior Member |
|
|
hai pink,
create the location table as follows
create table location
(locationid varchar2(20),
name varchar2(20),
managername varchar2(20))
alter table location add primary key(locationid,managername)
then create the worker table
create table worker(
workerid varchar2(20),
workername varchar2(20),locationid varchar2(20) references location(locationid),managername varchar2(20) references location(managername))
k.sreenivasan
|
|
|
Re: identification of foreign key [message #51277 is a reply to message #51266] |
Sat, 11 May 2002 21:58 |
pinky
Messages: 26 Registered: May 2002
|
Junior Member |
|
|
Hello sreenivasan,
The correct identification of primary key of location table is locationid alone.
Do you think I should call locationid and managername as foreign key in table worker.If you think so then I can create unique index of locationid and managername in table location. My problem is that can I identify logically locationid and managername as foreignkey in table worker?
Awaiting response.
Thanks...
|
|
|