DROP TABLE IF EXISTS Salary CASCADE;
CREATE TABLE Salary(
	id INT PRIMARY KEY,
	salary INT
);

DROP TABLE IF EXISTS Positions CASCADE;
CREATE TABLE Positions(
	id INT PRIMARY KEY,
	title VARCHAR(255)
);

DROP TABLE IF EXISTS People;
CREATE TABLE People(
	id INT PRIMARY KEY,
	name VARCHAR(255),
	position_id INT REFERENCES Positions(id),
	salary_id INT REFERENCES Salary(id)
);

INSERT INTO Salary VALUES (1, 10000), (2, 20000), (3, 3000);
INSERT INTO Positions VALUES (1, 'Дизайнер'), (2, 'Редактор'), (3, 'Программист');
INSERT INTO PEOPLE VALUES (1, 'Владмир', 1, 1), (2, 'Татьяна', 2, 2), (3, 'Александр', NULL, 2), (4, 'Борис', 2, NULL);

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People JOIN Positions on People.position_id = Positions.id;

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People RIGHT JOIN Positions on People.position_id = Positions.id;

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People LEFT JOIN Positions on People.position_id = Positions.id
EXCEPT
SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People JOIN Positions on People.position_id = Positions.id;

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People LEFT JOIN Positions on People.position_id = Positions.id
WHERE People.position_id ISNULL;

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People FULL JOIN Positions on People.position_id = Positions.id
WHERE Positions.id ISNULL OR People.id ISNULL;

SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People LEFT JOIN Positions on People.position_id = Positions.id
UNION
SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People RIGHT JOIN Positions on People.position_id = Positions.id
EXCEPT
SELECT People.id, People.name, Positions.id as pos_id, Positions.title FROM People JOIN Positions on People.position_id = Positions.id;

SELECT People.id, name, position_id,  title, salary_id, salary FROM People
JOIN Positions on People.position_id = Positions.id
JOIN Salary ON People.salary_id = Salary.id;