我想创建一个名为now shows(电影)的表,其中一列将是票价的票价我有3个选项银,金,白金,我知道我将不得不为票价创建不同的表但如何连接两个表?哪个字段对主键和外键更好?
答案 0 :(得分:0)
CREATE TABLE PRICES (
PriceID INT PRIMARY KEY AUTO-INCREMENT,
PriceOption STRING
);
CREATE TABLE NOWSHOWING (
MovieID INT PRIMARY KEY AUTO-INCREMENT,
PriceID INT FOREIGN KEY REFERENCES PRICES(PriceID),
[probably some more stuff]
);
INSERT INTO PRICES (PriceOption) VALUES ('Platinum');
INSERT INTO PRICES (PriceOption) VALUES ('Gold');
INSERT INTO PRICES (PriceOption) VALUES ('Silver');
这就是你要找的东西吗?