Search code examples
mysqlsqlerdweak-entity

Creating SQL Tables based on ERD with two Weak entities


Struggling with this issue i have. have been given a ERD that looks like this:

ERD Diagram

I am not sure how to join the 2nd Weak Entity (Charge Details) Below is the SQL that is throwing an error when attempting to insert data.

CREATE TABLE Charge_Details
(
actid NUMBER NOT NULL,
empid NUMBER NOT NULL,
weekno NUMBER (2),
hrsworked NUMBER (4,1),
PRIMARY KEY (actid, empid, hrswork),
FOREIGN KEY (actid) REFERENCES ACTOR,
FOREIGN KEY (empid) REFERENCES EMPLOYEE_DETAILS
);

Any help would be hugely appreciated!


Solution

  • Fixed it, silly mistake!

    PRIMARY KEY (actid, empid, weekno)

    thats what i need.