Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9195603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:39:50+00:00 2026-06-17T21:39:50+00:00

Take the following two tables in Oracle: Create Table A ( A int, B

  • 0

Take the following two tables in Oracle:

Create Table A
( A int, B int, C int,
  Constraint pk_ab Primary Key(A, B),
  Unique (C)
);

Create Table B
( D int, E int, F int,
  Constraint fk_d Foreign Key (D) References A(A),
  Constraint fk_e Foreign Key (E) References A(B)
);

Why doesn’t this statement work? Or more specifically, why shouldn’t it work? The reason I’m trying to create this type of relation is say, in the future, I want to delete B.D, but keep the relation FK_E.

I’m getting the error:

ORA-02270: no matching unique or primary key for this column-list

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:39:51+00:00Added an answer on June 17, 2026 at 9:39 pm

    “Why doesn’t this statement work? Or more specifically, why shouldn’t
    it work? “

    You have defined the primary key on A as a compound of two columns (A,B). Any foreign key which references PK_AB must match those columns in number. This is because a foreign key must identify a single row in the referenced table which owns any given row in the child table. The compound primary key means column A.A can contain duplicate values and so can column A.B; only the permutations of (A,B) are unique. Consequently the referencing foreign key needs two columns.

    Create Table B
    ( D int, E int, F int,
      Constraint fk_de Foreign Key (D,E) References A(A,B)
    );
    

    “Since there are multiple PK’s that table B references”

    Wrong. B references a single primary key, which happens to comprise more than one column,

    ” say, in the future, I want to delete B.D, but keep the relation
    fk_e. “

    That doesn’t make sense. Think of it this way: D is not a property of B, it is an attribute B inherits through its dependence on table A.

    One way to avoid this situation is to use a surrogate (or synthetic) key. Compound keys are often business keys, hence their columns are meaningful in a business context. One feature of meaningful column values is that they can change, and cascading such changes to foreign keys can be messy.

    Implementing a surrogate key would look like this:

    Create Table A
    ( id int not null, A int, B int, C int,
      Constraint pk_a Primary Key(ID),
      constraint uk_ab Unique (A,B)
    );
    
    Create Table B
    ( a_id int, F int,
      Constraint fk_n_a Foreign Key (A_ID) References A(ID)
    );
    

    Of course, you could kind of do this using the schema you posted, as you already have a single column constraint on A(C). However, I think it is bad practice to reference unique constraints rather than primary keys, even though it’s allowed. I think this partly because unique constraints often enforce a business key, hence meaning, hence the potential for change, but mainly because referencing primary keys just is the industry standard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with a many-to-one relationship. (Oracle) **Table: PARENT** Field: A (PK)
Take the following snippet: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int foo(char [6]);
I am stuck in the following situations. I have two tables Products and Postage
I have two tables stok and stok_detail.Table stock is a summary of table stock_detail.
The following SQL generates all matching records between two tables that have identical schemas
I have the following code that will join two different tables together and provide
I have two tables with the following columns: Table1 { ID NUMBER(15), ROLL_NUM VARCHAR2(9),
I have the following linq expression that lets me join two tables, group them
Given the following table partitioning under PostgreSQL 9.0.3: CREATE TABLE records ( ts TIMESTAMP,
I have two large tables -Master table A: 1.4million rows -Detail table B: 9

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.