MySQL Forums
Forum List  »  Quality Assurance

connect two tables in mysql
Posted by: Abubaker Theiban
Date: March 20, 2012 03:32AM

Hi all

I'm building my website in Dreamweaver.

I have create my database in localhost and it consist of 3 tables Guest , Room , Service.

Guest consist of:
ID , First Name , Second Name , Last Name , Mobile , E-mail , Age , Gender , Indentification ID , Arrival Date , Departure Date , Guest Number , Price.

Room
Room Number , Guest Room , Family Room , Businessman Room.

Service
Service ID , Meals Service , Communication Service , Mobility Service.

All I want is to connect the tables with each others so I put in the Guest table the primary key of Room (Room Number) , Service (Service ID) and I add them as INDEX in the options.

Then I start to test my website and when the explorer start it gives me the message :

Cannot add or update a child row: a foreign key constraint fails (`online hotel reservation system`.`room`, CONSTRAINT `room_ibfk_1` FOREIGN KEY (`Room Number`) REFERENCES `guest` (`Guest ID`))

I do not know what to do so please anyone help me.

Options: ReplyQuote


Subject
Views
Written By
Posted
connect two tables in mysql
4616
March 20, 2012 03:32AM
1105
March 30, 2012 01:02AM
1480
March 27, 2012 07:35AM
1068
March 30, 2012 01:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.