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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:19:29+00:00 2026-06-12T01:19:29+00:00

So, this is my input, I’m designing a hospital database and I’m creating a

  • 0

So, this is my input, I’m designing a hospital database and I’m creating a table that will hold the relationships between the patients in the ‘patients’ table and the rooms in the ‘room’ table (clever, I know).

here’s the statement is used to declare both tables:

create table patient_room
(
pr_id int NOT NULL PRIMARY KEY auto_increment,
patient_id int NOT NULL,
room_id int NOT NULL,
)ENGINE = InnoDB;

create table patients
(
patient_id int  primary key not null auto_increment,
fname varchar(30),
lname varchar(30),
suffix enum('I','II','III','IV','JR','SR'),
sex enum('M','F','U','T'),
eye_color enum('BK','BR','BL','GY','GR','HZ','MN','DX','UN'),
hair_color enum('BK','BR','BN','RD','WH','SN','BD','UN'),
date_of_birth date not null,
height int unsigned not null,
weight int unsigned not null,
admitted datetime not null
) Engine = InnoDB;

here’s my alter statement

alter table patient_room add foreign key (patient_id) references patient(patient_id) on delete cascade on update cascade;

I get the return:

ERROR 1005 (HY000): Can't create table 'Mthomas.#sql-3dac_5f1' (errno: 150)

I was able to alter the table to create a foreign key using

alter table patient_room add foreign key (room_id) references room(room_id) on delete cascade on update cascade;

without error. I do have have patient_id as a foreign key already on another patient_meds table, and I’m thinking that could be the issue… if so? How do I mitigate it?

  • 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-12T01:19:30+00:00Added an answer on June 12, 2026 at 1:19 am

    your table is called patients and not patient. You need to change

    alter table patient_room add foreign key (patient_id) references patient(patient_id) on delete cascade on update cascade;
    

    to

    alter table patient_room add foreign key (patient_id) references patients(patient_id) on delete cascade on update cascade;
                                                                            ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My trigger takes an input. (NEW:input_id) With this input, it will generate new ID's
I'm building a blog that should parse bbcode tags like this: Input: <youtube=http://www.youtube.com/watch?v=VIDEO_ID&feature=channel> Output:
I am trying to process some XML to reform it so that this input,
I have a list of files that look like this: Input /foo/bar/baz/d4dc7c496100e8ce0166e84699b4e267fe652faeb070db18c76669d1c6f69f92.mp4 /foo/baz/bar/60d24a24f19a6b6c1c4734e0f288720c9ce429bc41c2620d32e01e934bfcd344.mp4 /bar/baz/foo/cd53fe086717a9f6fecb1d0567f6d76e93c48d7790c55e83e83dd1c43251e40e.mp4
I have an input that contains a text. When I click into this input,
I have this input of type Submit that Watir cannot see. I can identify
I have this input that has text and when you click it, the text
Is there any PHP/GD function that can calculate this: Input: image width, image height
I have a website design that includes text input fields that look like this:
I have this input text: <html><head><meta http-equiv=content-type content=text/html; charset=utf-8></head><body><table cellspacing=0 cellpadding=0 border=0 align=center width=603>

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.