how to make a column a foreign key in phpmyadmin xampp

Solutions on MaxInterview for how to make a column a foreign key in phpmyadmin xampp by the best coders in the world

showing results for - "how to make a column a foreign key in phpmyadmin xampp"
Garman
28 Oct 2016
1DROP TABLE IF EXISTS `Customer`;
2/*!40101 SET @saved_cs_client     = @@character_set_client */;
3/*!50503 SET character_set_client = utf8mb4 */;
4CREATE TABLE `Customer` (
5  `CustomerID` varchar(45) NOT NULL,
6  `Username` varchar(45) NOT NULL,
7  `Password` varchar(45) NOT NULL,
8  `Gender` varchar(45) NOT NULL,
9  `DoB` date NOT NULL,
10  `AddressID` varchar(45) NOT NULL,
11  `ContactID` varchar(45) NOT NULL,
12  `Picture` blob NOT NULL,
13  PRIMARY KEY (`CustomerID`),
14  KEY `AddressID` (`AddressID`),
15  KEY `ContactID` (`ContactID`),
16  CONSTRAINT `AddressID` FOREIGN KEY (`AddressID`) REFERENCES `Addresses` (`AddressID`) ON DELETE CASCADE ON UPDATE CASCADE,
17  // There Must be a Table Called Addresses which holds a Column AddressID as PRIMARY KEY
18  CONSTRAINT `ContactID` FOREIGN KEY (`ContactID`) REFERENCES `Contacts` (`ContactID`) ON DELETE CASCADE ON UPDATE CASCADE
19    // There Must be a Table Called Contacts which holds a Column ContactID as PRIMARY KEY
20) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
21
22@Zenonymous