3

I'm new to database and my entity-relationship diagram is as follows:

enter image description here

According to that I designed my SQL-DDL database statements as shown below:

CREATE TABLE Developer (
    DeveloperID int NOT NULL AUTO_INCREMENT,
    Name varchar(255),
    Primary key(DeveloperID)
);

CREATE TABLE Manager (
    ManagerID int NOT NULL AUTO_INCREMENT,
    Name varchar(255),
    Primary key(ManagerID)
);

CREATE TABLE Project (
    ProjectID int AUTO_INCREMENT,
    Name varchar(255),
    ManagerID int,
    Primary key(ProjectID),
    CONSTRAINT FK_Manager FOREIGN KEY (ManagerID) REFERENCES Manager(ManagerID)
);

CREATE TABLE Task (
    TaskID int AUTO_INCREMENT,
    DeveloperID int NOT NULL,
    ProjectID int NOT NULL,
    Descriptions varchar(255),
    Primary key(TaskIDTaskID),
    CONSTRAINT FK_Developer FOREIGN KEY (DeveloperID) REFERENCES Developer(DeveloperID),
    CONSTRAINT FK_Project FOREIGN KEY (ManagerID) REFERENCES Project(ProjectID)
);

But I'm not sure if this is correct or not, because I'm not using any other table for works (there are many-to-many relationships). If I create a table for that, I think it's useless for me. Can anyone tell me if this structure is correct or not? If incorrect, please tell me what should I do to improve it.

  • 1
    Can't judge a schema until you have written the SELECTs. – Rick James Mar 19 '18 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.