我与 MySQL 的关系有问题。有人可以告诉我这是否是一对一的关系(帐户和客人之间)。
CREATE TABlE IF NOT EXISTS account
(
accountID INT UNSIGNED NOT NULL COMMENT 'primary key',
guestFK INT UNSIGNED NOT NULL COMMENT 'account linked to particular guest',
password VARCHAR(20) NOT NULL COMMENT 'password of guest account',
CONSTRAINT account_PK PRIMARY KEY (accountID),
CONSTRAINT account_FK FOREIGN KEY (accountID) REFERENCES hotel.guest(guestID)
);
CREATE TABLE IF NOT EXISTS guest
(
guestID INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'primary key',
addressFK INT UNSIGNED NOT NULL COMMENT 'foreign key of guest address',
vehicleFK INT UNSIGNED COMMENT 'foreign key of guest vehicle',
firstName VARCHAR(50) NOT NULL COMMENT 'first name of guest',
lastName VARCHAR(50) NOT NULL COMMENT 'last name of guest',
phoneNum INT UNSIGNED NOT NULL COMMENT 'phone number of guest',
eMail VARCHAR(50) NOT NULL COMMENT 'e-mail address of guest',
CONSTRAINT guest_PK PRIMARY KEY (guestID),
CONSTRAINT address_FK FOREIGN KEY (addressFK) REFERENCES hotel.address(addressID),
CONSTRAINT vehicle_FK FOREIGN KEY (vehicleFK) REFERENCES hotel.vehicle(vehicleID),
CONSTRAINT email_UQ UNIQUE (eMail) COMMENT 'no two guests should have the same e-mail address',
CONSTRAINT guest_UQ UNIQUE (firstName, lastName, phoneNum) COMMENT 'no two guests should have same name and phone number'
);