If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > column Names

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-04, 13:00
wallaceoc80 wallaceoc80 is offline
Registered User
 
Join Date: Aug 2004
Posts: 5
column Names

Is it wrong to have many different tables with a primary key of the same name and effectively they refer to the same number?

For example:

I have an APP table with primary key AppID.

I also have an AppContacts table with primary key AppID.

I also have a FAQ table with FaqID as the primary key and AppID as another column so that I can link these 2 tables.

The reason I have the same column names is because I need a way to link both tables. Can anybody see a problem with this?

Regards,

Wallace
Reply With Quote
  #2 (permalink)  
Old 08-16-04, 16:19
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
That all seems quite normal, except where you say AppID is the primary key of AppContacts as well as of App. That means there is a 1:1 correspondence between App and AppContacts; is that what you want? If it is, fine.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 08-17-04, 06:47
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
Quote:
The reason I have the same column names is because I need a way to link both tables.
Column names (in Oracle) do NOT have to have the same names in order to be linked by the mean of a foreign key (referential integrity constraint).

Quote:
Also have a FAQ table with FaqID as the primary key and AppID as another column so that I can link these 2 tables.
I guess you'd like to link tables "FAQ" and (one of, or both) "APP" / "APPCONTACTS". Well, everything is fine - just like Tony already said, regarding the fact that you can not create foreign key from faq.appID to both app.appID and appcontacts.appID (but you can create two foreign keys from app.appID to faq.appID and from appcontacts.appID to faq.appID).

I'd just like to add that having AppID columns in those tables as primary keys (unique constraint would also work) is necessary if you want to create foreign keys from FAQ to those tables. Creating unique index (for example, just to show similarity between "unique key constraint" and "unique index" names) would not allow you to do so.

Last edited by Littlefoot; 08-17-04 at 07:10.
Reply With Quote
  #4 (permalink)  
Old 08-17-04, 09:05
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Littlefoot
Column names (in Oracle) do NOT have to have the same names in order to be linked by the mean of a foreign key (referential integrity constraint).
this is true in all databases that i'm familiar with
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On