/* Create Hotel Table */
CREATE TABLE Hotel (
hotelNo numeric(10),
hotelName varchar(20),
city nvarchar (10),
CONSTRAINT hotel_PK PRIMARY KEY(hotelNo));
/* Create Room Table */
CREATE TABLE Room (
roomNo numeric(10),
hotelNo numeric(10),
type nvarchar (20),
price money,
CONSTRAINT room_PK PRIMARY KEY (roomNo, hotelNo),
CONSTRAINT hotel_FK FOREIGN KEY (hotelNo) REFERENCES Hotel(hotelNo) );
/* Insert into Hotel Table */
INSERT INTO Hotel VALUES
(5431, 'Ritz', 'London'),
(5551, 'Marriott', 'London'),
(3451, 'Marriott', 'Paris'),
(1122, 'Riverside', 'Berlin'),
(1342, 'Imperial', 'London'),
(7782, 'Triumph', 'Paris');
/* Insert into Room Table */
INSERT INTO Room VALUES
(910, 5551, 'Double', 255),
(915, 5551, 'Family', 345),
(448, 7782, 'Double', 15),
(110, 1122, 'Double', 39),
(910, 1345, 'Single', 27),
(448, 1121, 'Suite', 115);
Msg 547, Level 16, State 0, Line 3
The INSERT statement conflicted with the FOREIGN KEY constraint "hotel_FK". The conflict occurred in database "mydb", table "mydb.Hotel", column 'hotelNo'.
The statement has been terminated.
(910, 1345, 'Single', 27)
(448, 1121, 'Suite', 115)
လှိုက်လှဲစွာကြိုဆိုပါသည်။ ယခု ပထမဆုံးအကြိမ် ရောက်ဖူးခြင်းဖြစ်ပါသလား? ဝင်ရောက် ဆွေးနွေး မေးမြန်းလိုပါလျှင် အောက်တွင်ဖော်ပြထားသော button များမှတဆင့် ဝင်ရောက် ဆွေးနွေးနိုင်သကဲ့သို့ အဖွဲ့ဝင်အသစ်အနေဖြင့်လည်း လျှောက်ထားနိုင်ပါတယ်။