I am working on an assignment for class where I have to take an ERD and create SQL statements to capture the relations. I am asking if the SQL statements I have created capture these relationships. In particular, I believe that “Dependent” is a weak entity and I do not know how to capture this relationship.
The ERD: https://i.stack.imgur.com/lkL1E.jpg

Here are my SQL statements:
CREATE TABLE Employees (
ssn INTEGER, salary REAL, phone VARCHAR(24), PRIMARY KEY (ssn))
CREATE TABLE Departments (
dno INTEGER, dname VARCHAR(150), budget REAL, PRIMARY KEY (dno),
managerid INTEGER, FOREIGN KEY (managerid) REFERENCES Employees (ssn))
CREATE TABLE Works_in (
eid INTEGER, did INTEGER, PRIMARY KEY (ssn, did), FOREIGN KEY (ssn)
REFERENCES Employees(eid), FOREIGN KEY (did) REFERENCES Dept (did))
CREATE TABLE Child (
parentssn INTEGER, name VARCHAR(50), age INTEGER, FOREIGN KEY (parentssn) REFERENCES Employees (ssn))
If it is not acceptable to post homework questions, please feel free to delete this.
I appreciate any and all help.
Thank you!
You did a good try.
Works_In is a relationship not a table.
So every employee will have a departmentid which references the department table.