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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:50:40+00:00 2026-06-13T09:50:40+00:00

Here’s my problem when I write my SQLSever expressions: There are no primary or

  • 0

Here’s my problem when I write my SQLSever expressions:

There are no primary or candidate keys in the referenced table ‘Room’
that match the referencing column list in the foreign key ‘FK_Booking_RoomNo__4E298478′.

And some snapshots to my program:

CREATE TABLE Booking(
   HotelNo  NVARCHAR(4)     not null,
   GuestNo      SMALLINT,  
   DateFrom DATETIME    not null,
   DateTo       DATETIME,
   RoomNo       SMALLINT    not null,

   PRIMARY KEY (HotelNo,DateFrom,RoomNo), 
   FOREIGN KEY (HotelNo) REFERENCES Hotel(HotelNo),
   FOREIGN KEY (GuestNo) REFERENCES Guest(GuestNo),
   FOREIGN KEY (RoomNo) REFERENCES Room(RoomNo));  <---trouble on this line

CREATE TABLE Room(
   RoomNo       SMALLINT    not null, 
   HotelNo  NVARCHAR(4)     not null, 
   RoomType     NVARCHAR(25),
   Price        DECIMAL(5,2),

   PRIMARY KEY (RoomNo,HotelNo), 
   CONSTRAINT fk_Room FOREIGN KEY (HotelNo) REFERENCES Hotel(HotelNo));

and here is the Hotel table

CREATE TABLE Hotel(
   HotelNo  NVARCHAR(4)     not null,
   HotelName    NVARCHAR(25),
   City     NVARCHAR(25),

   PRIMARY KEY (HotelNo) );

I tried to do some search on this problem, and it says this might be caused when there’s no primary key defined in the table Room, but as above, it is defined.

Can someone please help me with this problem?

Thank you in advance.

  • 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-13T09:50:41+00:00Added an answer on June 13, 2026 at 9:50 am

    Any reference to composite key must also include both columns.

    FOREIGN KEY (RoomNo, HotelNo) REFERENCES Room(RoomNo, HotelNo))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the problem that I am trying to solve. I have two folders
Here's the code I have. It works. The only problem is that the first
Here's a coding problem for those that like this kind of thing. Let's see
Here is another spoj problem that asks how to find the number of distinct
Here is a simple function which i made on PHP. The problem is that
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here is an example: I write html code inside of textarea, then I swap
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the

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.