所以我有这个数据库
ALTER TABLE `Partcar` (
`partcarID` Char(7) NOT NULL,
`partcar_price` decimal(19,4) DEFAULT NULL,
`partcar_name` varchar(100) DEFAULT NULL,
`carIDFK` int(10) NOT NULL,
PRIMARY KEY (`PartcarID`)
UNIQUE KEY `car` (`carID`)
CONTRAINT carIDFK FOREIGN KEY (`carIDK`) REFERENCES car(`carID`)
);
CREATE TABLE `car` (
`carID` Char(7) NOT NULL,
`name_car` varchar(100) DEFAULT NULL,
`car_price` decimal(19,4) DEFAULT NULL,
PRIMARY KEY (`PCID`)
);
ALTER TABLE `assembly` (
`assemblyID` char(8) NOT NULL,
`assembly_price` decimal(19,4) DEFAULT NULL,
`partcarIDFK` int(10) NOT NULL,
`barbellIDFK` int(10) NOT NULL,
PRIMARY KEY (`assemblyID`),
UNIQUE KEY `partcar` (`partcarIDFK`),
UNIQUE KEY `barbell` (`barbellIDFK`),
CONSTRAINT `partcarIDFK` FOREIGN KEY (`partcarIDFK`) REFERENCES partcar(`partcarID`),
CONSTRAINT barbellIDFK FOREIGN KEY (`barbellIDFK`) REFERENCES barbell(`barbellID`)
);
ALTER TABLE `barbell` (
`barbellID` char(10) NOT NULL,
`name_barbell` varchar(100) DEFAULT NULL,
`carIDFK` int(10) NOT NULL,
PRIMARY KEY (`barbellID`),
UNIQUE KEY `car` (`carID`),
CONTRAINT carIDFK FOREIGN KEY (`carIDK`) REFERENCES car(`carID`)
);
所以,通过这3个表,我混淆了如何连接其中的3个并且我正在考虑与barbell
和partcar
建立与assembly
的多对多关系,
所以这是值的样本
装配和汽车输出
| Code Car(CarID) + Assembly |
-------------------------
| C1234 - B123456 |
该代码是查看该部分的链接。
汽车+零件输出
| No. | IDcar + IDpart | Description | Price |
----------------------------------------------
| 1 | C1234 - A333 | Interior | $1 |
| 2 | C1234 - B444 | Chassis | $2 |
关于杠铃输出
| No. | IDcar | ID Barbell | Description | Price |
-----------------------------------------------------
| 1 | C1234 | 1234-1111 | Big Wheel | $1 |
| 2 | C1234 | 1234-2222 | Wide Wheel | $2 |
OR
装配和汽车输出
| Code Car + Assembly | ID Partcar, ID barbell | Description | Qty
-----------------------------------------------------------------------
| C1234 - B123456 | | 96' Cougar |
| A333 | Interior | 1
| B444 | Chassis | 1
| 1234-1111 | Big Wheels | 1
| 1234-2222 | Wide Wheels | 1
这是表格,所以我只是想知道,与此有什么关系以及如何用PHP调用它们?
*描述是汽车,零件和杠铃的名称。和代码车是carID
*注意:不要担心表格,我只是想知道如何连接它们以及如果这样的表格如何调用它。