-- FIRST APPROACH

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

CREATE TABLE Room(
  name TEXT,
  size TEXT,
  PRIMARY KEY (name)
);

CREATE TABLE Lecture (
  name TEXT PRIMARY KEY REFERENCES Room
);

CREATE TABLE Office (
  name TEXT PRIMARY KEY REFERENCES Room
);

CREATE TABLE ComputerRoom (
  name TEXT PRIMARY KEY REFERENCES Room,
  computers INT CHECK (computers>0)
);


-- This fails
INSERT INTO Office VALUES ('office1');


INSERT INTO Room VALUES ('name1');
INSERT INTO Office VALUES ('name1');

-- Is this possible??
INSERT INTO Lecture VALUES ('name1');
INSERT INTO ComputerRoom VALUES ('name1',1);