DROP SCHEMA IF EXISTS lecture7ex3b CASCADE;
CREATE SCHEMA lecture7ex3b;
SET SCHEMA 'lecture7ex3b';

CREATE TABLE Person (
  ssn INT PRIMARY KEY,
  name TEXT NOT NULL
);

-- Second Scenario
CREATE TABLE Pet(
  name TEXT,
  ssn INT REFERENCES Person NOT NULL,
  PRIMARY KEY (name, ssn)
);

INSERT INTO Person VALUES (1, 'Name1');
INSERT INTO Person VALUES (2, 'Name2');
INSERT INTO Person VALUES (3, 'Name3');


INSERT INTO Pet VALUES ('Pet1',1);
INSERT INTO Pet VALUES ('Pet2',2);
INSERT INTO Pet VALUES ('Pet3',3);

-- This works 
INSERT INTO Pet VALUES ('Pet3',1);
-- BUT 
INSERT INTO Pet VALUES ('Pet3',1);