Answer the question
In order to leave comments, you need to log in
How to bind a key in tables?
How can I do a substitution of multiple values from one table to another?
Answer the question
In order to leave comments, you need to log in
The orders
table must have a person_id foreign key that refers to the person table as the primary key.
Actually it looks like this
CREATE TABLE `persons` (
`id` INT(10,0) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`phone` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB;
CREATE TABLE `orders` (
`id` INT(10,0) NOT NULL AUTO_INCREMENT,
`date` DATETIME NULL DEFAULT NULL,
`person_id` INT(10,0) NOT NULL DEFAULT '0',
`street` VARCHAR(255) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_unicode_ci',
`name` VARCHAR(255) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_unicode_ci',
`phone` VARCHAR(50) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_unicode_ci',
PRIMARY KEY (`id`) USING BTREE,
INDEX `person_id` (`person_id`) USING BTREE,
CONSTRAINT `FK1_OP` FOREIGN KEY (`person_id`) REFERENCES `rmok`.`persons` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question