1. One-To-One Relationship - Exercises: Table Relations
Защо задачата гърми след като в базата се запаметяват закръглени стойностти както е по условие?
CREATE TABLE `people` (
`person_id` INT NOT NULL,
`first_name` VARCHAR(20),
`salary` DOUBLE(7,2),
`passport_id` INT UNIQUE
);
CREATE TABLE `passports` (
`passport_id` INT NOT NULL UNIQUE,
`passport_number` VARCHAR(20) UNIQUE
);
ALTER TABLE `people`
ADD PRIMARY KEY (`person_id`);
ALTER TABLE `people`
ADD CONSTRAINT `fk_people_passports`
FOREIGN KEY (`passport_id`) REFERENCES passports(passport_id);
INSERT INTO `passports`
(`passport_id`, `passport_number`)
VALUES
('101', 'N34FG21B'),
('102', 'K65LO4R7'),
('103', 'ZE657QP2');
INSERT INTO `people`
(`person_id`, `first_name`, `salary`, `passport_id`)
VALUES
('1', 'Roberto', ROUND('43300', 2), '102'),
('2', 'Tom', ROUND('56100', 2), '103'),
('3', 'Yana', ROUND('60200', 2), '101');