This question I was asked from a startup company.
A construction manager works for a home building company. They need to supervise many projects at once.
Users can follow updates on a project
Users can post updates on a project
Users can see 50 most recent updates across projects they follow
Design a relational database schema for this product.Interviewer told me that you have a construction website where managers can go and do the above. I did below:
CREATE TABLE IF NOT EXISTS construction.follow_updates (
project_id BIGINT(20) NOT NULL AUTO_INCREMENT,
project_name VARCHAR(30) NOT NULL,
manager_assigned VARCHAR(30) NOT NULL,
comments VARCHAR(50),
project_start_date DATE NOT NULL,
PRIMARY KEY(project_id)
);
CREATE INDEX project_name ON follow_updates;
CREATE TABLE construction.recent_updates (
project_id_update BIGINT NOT NULL ‘Parent foreign key’,
);
select TOP 50 recent_updates.project_id_update, follow_updates.project_id, follow_updates, project_name
from follow_updates
INNER JOIN recent_updates ON
recent_updates.project_id_update = follow_updates.project_id;Please suggest what do you think could be a possible solution for this database schema and where did I go wrong?