the problem statement is :
The database :
Emp(eid: integer, ename:
string, age: integer , salary: real)
Works(eid: integer, did: integer, pct time: integer)
Dept(did: integer, budget: real , managerid: integer)
Query :. Define a table constraint on Dept that will ensure that all managers have age > 30
and the solution i tried is:
CREATE TABLE Dept ( did INTEGER,
buget REAL ,
managerid INTEGER ,
PRIMARY KEY (did),
FOREIGN KEY (managerid) REFERENCES Emp,
CHECK( ( SELECT E.age FROM Emp E, Dept D)
WHERE E.eid = D.managerid ) > 30 ))
but it's not working , giving error as
Subquery not allowed here .
What may b the problem in this solution ?