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

  • SEARCH
  • Home
  • 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 8819925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:29:00+00:00 2026-06-14T05:29:00+00:00

Firstly I created a CourseSections table like below: Create Table CourseSections( CourseNo Integer NOT

  • 0

Firstly I created a CourseSections table like below:

Create Table CourseSections(
 CourseNo    Integer NOT NULL CHECK(CourseNo BETWEEN 100 AND 999),
 SectionNo   Integer NOT NULL,
 InstructorNo Integer NOT NULL,
 Year        Integer NOT NULL,
 Semester    Integer NOT NULL,
 FOREIGN KEY(CourseNo) REFERENCES Courses(CourseNo),
 PRIMARY KEY(SectionNo, Year, Semester)
);

Then I created another table that has foreign keys referencing to table CourseSections keys:

  Create Table Enrollments(
     CourseNo     Integer NOT NULL CHECK(CourseNo BETWEEN 100 AND 999),
     Semester     Integer NOT NULL,
     Year         Integer NOT NULL,
     SectionNo    Integer NOT NULL,
     FOREIGN KEY(CourseNo) REFERENCES Courses(CourseNo),
     FOREIGN KEY(Year) REFERENCES CourseSections(Year),
     FOREIGN KEY(Semester) REFERENCES CourseSections(Semester),
     FOREIGN KEY(SectionNo) REFERENCES CourseSections(SectionNo)  

);

Then I’m getting an error message saying

    There are no primary or candidate keys in the referenced table 'CourseSections'   
    that match the referencing column list in the foreign key 
    FK__Enrollment__Year__3890146B'.

The rest foreign keys are all fine except the ones referencing to the table CourseSections. Can anyone tell me where the problem is? Very much appreciated!!

  • 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-14T05:29:01+00:00Added an answer on June 14, 2026 at 5:29 am
    FOREIGN KEY(SectionNo) REFERENCES CourseSections(SectionNo)
    

    should work, but the other foreign keys will not since they don’t really have an index; they are lower parts of a composite index. A composite index is used for columns only in order of how it was created. You would either needs to make unique indexes on CourseSections.Year and CourseSections.Semester, or, more likely, create a single composite foreign key like this:

    FOREIGN KEY(SectionNo, Year, Semester) REFERENCES CourseSections(SectionNo, Year, Semester)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MySQL v5.1. I would like to create index on a table
Firstly I created a collection which is Collection list; and in a function RSS
I have created firstly ASP.NET MVC 2 . and write more functionality. After I
I am a little bit confused about 2 things. Firstly when I create an
Firstly, I wrote my customized setter for an NSString* like this: - (void)setDateString:(NSString *)newDateString
Short story. This site was created by a friend of mine, who did not
Firstly I would like to say that I am quite new to Spring (in
Firstly I'd like to say my knowledge on Excel is fairly limited, and I'm
I have an EDIT control created like this: hwndEDIT_5 = CreateWindowEx ( 0, EDIT,
Firstly I created the ArrayList of Strings: List<List<String>> array1 = new ArrayList<List<String>>(); Then after

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.