Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE persons(
- person_id INT(11) NOT NULL,
- fist_name VARCHAR(50),
- salary DECIMAL(15,2),
- passport_id INT(11)
- );
- CREATE TABLE passports(
- passport_id INT(11) NOT NULL,
- passport_number VARCHAR(50)
- );
- INSERT INTO persons
- VALUES
- (1, 'Roberto', 43300.00, 102),
- (2, 'Tom', 56100.00, 103),
- (3, 'Yana', 60200.00, 104);
- INSERT INTO passports
- VALUES
- (102, 'N34FG21B'),
- (103, 'K65LO4R7'),
- (104, 'ZE657QP2');
- ALTER TABLE persons
- ADD CONSTRAINT pk_person_id PRIMARY KEY(person_id);
- ALTER TABLE passports
- ADD CONSTRAINT pk_passport_id PRIMARY KEY(passport_id);
- ALTER TABLE persons
- ADD CONSTRAINT fk_passport_id FOREIGN KEY(passport_id) REFERENCES passports(passport_id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement