Results 1 to 4 of 4

Thread: column Names

  1. #1
    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

  2. #2
    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.

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    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).

    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 08:10.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •