CREATE TABLE buildings (
building_no int(11) NOT NULL AUTO_INCREMENT,
building_name varchar(255) NOT NULL,
address varchar(355) NOT NULL,
PRIMARY KEY (building_no)
) ENGINE=InnoDB;
CREATE TABLE rooms (
room_no int(11) NOT NULL AUTO_INCREMENT,
room_name varchar(255) NOT NULL,
building_no int(11) NOT NULL,
PRIMARY KEY (room_no),
KEY building_no (building_no),
CONSTRAINT rooms_ibfk_1
FOREIGN KEY (building_no)
REFERENCES buildings (building_no)
ON DELETE CASCADE
) ENGINE=InnoDB;
No comments:
Post a Comment