mysql. Создаю БД с тремя таблицами - buildings - rooms - seatsприблизительно набросал: КодSQL CREATE TABLE buildings (buildingId INTEGER AUTOINCREMENT NOT NULL, title VARCHAR(100) NOT NULL, PRIMARY KEY (buildingId)); CREATE TABLE rooms (roomId INTEGER AUTOINCREMENT NOT NULL, title VARCHAR(100) NOT NULL, buildingId INTEGER NOT NULL, PRIMARY KEY (roomId), FOREIGN KEY (buildingId) REFERENCES buildings(buildingId) ON UPDATE CASCADE ON DELETE RESTRICT ) ENGINE=InnoDB CHARACTER SET=UTF8; CREATE TABLE seats (seatId INTEGER AUTOINCREMENT NOT NULL, title VARCHAR(100) NOT NULL, roomId INTEGER, buildingId INTEGER, PRIMARY KEY (seatId), FOREIGN KEY (roomId) REFERENCES rooms(roomId) ON UPDATE CASCADE ON DELETE RESTRICT, FOREIGN KEY (buildingId) REFERENCES buildings(buildingId) ON UPDATE CASCADE ON DELETE RESTRICT ) ENGINE=InnoDB CHARACTER SET=UTF8;Правильно ли я связываю таблицу seats с buildings?
|