19.3. Romley’s Division

This somewhat complicated relational division is due to Richard Romley at Salomon Smith Barney. The original problem deals with two tables. The first table has a list of managers and the projects they can manage. The second table has a list of Personnel, their departments, and the projects to which they are assigned. Each employee is assigned to one and only one department, and each employee works on one and only one project at a time. But a department can have several different projects at the same time, and a single project can span several departments.

CREATE TABLE MgrProjects (mgr_name CHAR(10) NOT NULL, project_id CHAR(2) NOT NULL, PRIMARY KEY(mgr_name, project_id)); INSERT INTO Mgr_Project VALUES ('M1', 'P1'), ('M1', ...

Get Joe Celko's SQL for Smarties, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.