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 3987872
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:11:07+00:00 2026-05-20T06:11:07+00:00

I just wanna ask coz I created a table with a column with two

  • 0

I just wanna ask coz I created a table with a column with two primary keys as shown below:

CREATE TABLE Parent(
Mother varchar(50) NOT NULL,
Father varchar(50) NOT NULL,
PRIMARY KEY(Mother, Father),
Organization varchar(50) NOT NULL
);

Then I am trying to create another table which will have a foreign key to the table shown above:

CREATE TABLE Child(
Name varchar(50) NOT NULL PRIMARY KEY,
Child_Mother varchar(50) REFERENCES Parent(Mother),
Child_Father varchar(50) REFERENCES Parent(Father),
Sibling varchar(50) NOT NULL
);

So I basically am trying to references two columns on the Child Table to a single column from the Parent table with two primary keys. Is this even possible? Thank you very much! 🙂

*Sample Tables only. But the actual are similar to this.

  • 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-05-20T06:11:08+00:00Added an answer on May 20, 2026 at 6:11 am

    Try this one –

    CREATE TABLE Child(
        Name varchar(50) NOT NULL PRIMARY KEY,
        Child_Mother varchar(50),
        Child_Father varchar(50),
        Sibling varchar(50) NOT NULL,
        Foreign Key (Child_Mother, Child_Father) references Parent(Mother, Father)
    );
    

    Since you are creating a primary key which consists of two columns, you need to refer to them together.

    What paxdiablo said is true. You are creating a composite primary key which consists of two columns. I would suggest you to use a Surrogate Primary Key.

    Edit

    CREATE TABLE Child(
        id bigint NOT NULL auto_increment,  // an "id" column
        Name varchar(50) NOT NULL unique,
        age int not null,
        primary key (id)    // "id" column is being declared as surrogate primary key
    );
    

    Second Edit

    create table Subject(
    
        id int not null,
        Subject_ID varchar(50) NOT NULL,
        Subject_Description varchar(50) NOT NULL,
        PRIMARY KEY(id),
        Subject_SID int references Student(Student_ID),
        Unit varchar(50) NOT NULL
    );
    
    ALTER TABLE Subject ADD CONSTRAINT subject_unique UNIQUE (Subject_id, Subject_Description);
    
    create table Schedule(
        Day_MTWTHF varchar(50) NOT NULL,
        TIME_HH varchar(50) NOT NULL,
        subject_id int not null,                   -- my newly added column
        Schedule_SID int references Student(Student_ID),
        foreign key(subject_id) references Subject(id)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanna ask if there's a way in C#/ASP.NET to create 'dynamic' tables/fields
just wanna ask what is acceptable size of ViewState per page? What is the
I just wanna ask what would be better approach to supply these objects in
I just wanna ask best practice supposed I have three tables. posts, categories, post_Categories.
I just wanna ask if there's a way where I could put an object
I just wanna ask your opinion/suggestion on how to 'terminate' a running application/process is
I just wanna ask if there's a possibility to retrieve the contents of a
i am using vb.net i just wanna ask if we can place a picture
Just what the title says, I need to change the password for an existing
Just looking for the first step basic solution here that keeps the honest people

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.